iPhone应用程序和Java Server之间的连接

时间:2014-06-06 17:32:47

标签: java ios sockets

我想在IOS Simulator和Java Server之间建立连接。这是IOS方面:

 NSInputStream *in;
 NSOutputStream *out;

CFReadStreamRef readStream;
CFWriteStreamRef writeStream;

CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.11", 10025, &readStream, &writeStream);

in = (__bridge NSInputStream *)readStream;
out = (__bridge NSOutputStream *)writeStream;

[in setDelegate:self];
[out setDelegate:self];

[in scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[out scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[in open];
[out open];

这是服务器端:

构造

iphoneSocket = new ServerSocket(10025);

在线程中:

           DataOutputStream dOut;
           DataInputStream dIn;

          try {

            System.out.println("Lyssnar efter iphones");
            thirdSocket = iphoneSocket.accept();
            dOut = new DataOutputStream(thirdSocket.getOutputStream());
            dIn = new DataInputStream(thirdSocket.getInputStream());
            System.out.println("Connected from " + thirdSocket.getInetAddress().getHostAddress());

            } catch (IOException ex) {
                Logger.getLogger(QuizWalkServer.class.getName()).log(Level.SEVERE, null, ex);
            }

问题在于我无法连接。我没有收到控制台中的消息。什么可能是错的?

汉克

0 个答案:

没有答案