I need to communicate between a Java app (desktop) and an iOS app. I've decided to use AsyncSocket
on the iPhone side (and I've gotten data sending to work). For this question, I'm just running the EchoServer
demo app on OSX 10.6.4. Source code is here.
Here's my Java code, boiled-down:
Socket echoSocket = new Socket("192.168.0.102", 8085);
PrintWriter out = new PrintWriter(echoSocket.getOutputStream(), true);
out.println("hello there!");
out.flush();
This works and the "hello there!" shows up on a TCP Monitor.
On the EchoServer
, the output is just
Accepted client 192.168.0.102:4960
So I know they're talking but I cannot get the data!
Edit: On the Java side (with more code), I do receive the Welcome to the "AsyncSocket Echo Server" message.
Edit: If I browse to the server it works perfectly, so the problem is in my Java code. What else do I need to do for a complete write to a socket correctly?