简体   繁体   English

具有Java Server-Side的iOS组播客户端系统

[英]Multicast Client System for iOS with a Java Server-Side

CONTEXT: 内容:

I am creating a cross-platform multicast client-server system for mobile. 我正在为移动设备创建一个跨平台的多播客户端-服务器系统。 I have created the server side in Java. 我已经用Java创建了服务器端。 I also created the android client side and it works perfectly. 我还创建了android客户端,它可以完美运行。

WHAT I WANT TO KNOW: 我想知道的是:

I want to know if I could create a client side in iOS using the listener program in this example http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/example.html that would be compatible with my server-side that I created in Java. 我想知道是否可以在本示例中使用侦听器程序在iOS中创建客户端http://ntrg.cs.tcd.ie/undergrad/4ba2/multicast/antony/example.html与我的服务器兼容-我用Java创建的一面。

If the above example will not work is there a way I can still use my Java server-side and create a native iOS client system that is compatible with the Java server-side? 如果上面的示例不起作用,是否仍然可以使用Java服务器端并创建与Java服务器端兼容的本机iOS客户端系统?

SAMPLE CODE OF JAVA SERVER SIDE FOR REFERENCE: Java服务器端的示例代码供参考:

import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
//more imports...

class Server2 {

    public static MulticastSocket ms1;

    public static void main(String[] args) throws IOException {

            try {
                InetAddress sessAddr1 = InetAddress.getByName("224.2.76.24");
                ms1 = new MulticastSocket(5500);
                ms1.joinGroup(sessAddr1);

                 while(true) {
                    byte[] message = new byte[1024];
                    message = getIpAddress().getBytes(); 
                    DatagramPacket dp = new DatagramPacket(message, message.length, sessAddr1, 5500);
                    ms1.send(dp);               
                    System.out.println(String.format("Sent message: %s", message));

                    Thread.sleep(1000);
                }
            } catch (Exception e) {
                System.out.println(String.format("Error: %s", e));
            }     
    }

    public static String getIpAddress() {
        InetAddress ip;

        try {
            ip = InetAddress.getLocalHost();
            return(String.format("%s",ip.getHostAddress()));     
        } catch (Exception e) {
            return("false");
        }
    }
}

I tested the listener code in the link and it worked perfectly. 我在链接中测试了侦听器代码,它运行良好。

Should not be a problem. 应该没问题。 iOS is POSIX compliant and Objective-C is defined on top of ANSI C, so you could paste the code you linked to with minor modifications straight into your project, build a simple wrapper to Objective-C and your app should compile, run and work as desired. iOS符合POSIX,并且Objective-C是在ANSI C的基础上定义的,因此您可以将进行了少量修改的链接的代码直接粘贴到项目中,为Objective-C构建一个简单的包装,并且您的应用应可以编译,运行和运行如预期的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 服务器端Java错误 - Server-side Java error 客户端Google Earth + JS; 服务器端Java包 - Client-side Google Earth + JS; server-side Java package 使用Dojo文件上传客户端将其他数据发送到Java服务器端 - Send additional data to Java server-side using Dojo file upload client-side 在JAVA和Servlet中客户端和服务器端之间进行数据库调用的安全方法? - Safe method for database calls between client-side and server-side in JAVA & Servlet? JSON(客户端)&lt;-&gt; Java(服务器端)&lt;-&gt; JSON(NoSQL DB) - JSON (client-side) <-> Java (server-side) <-> JSON (NoSQL DB) 需要在HTML + JavaScript的客户端和Java / C ++的服务器端程序之间进行通信 - Need to communicate between Client-side in HTML+JavaScript and Server-side program in Java/C++ 客户端上的Java客户端-服务器问题(无System.out) - java client-server issue on client side (no System.out) Java中为客户端/服务器端双向通信反馈系统搭建服务器? - Build a server for client/server side bidirectional communication feedback system in Java? 如何检查进程是否在客户端计算机上(在服务器端)运行? [Java] - How to check if a process is running on a client's computer (on server-side)? [Java] Java服务器端屏幕分辨率检测 - Java Server-Side screen resolution detection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM