views:

40

answers:

1

So I'm writing an application for my iphone that networks to my computer running a java application using AsyncSocket. On the java side, it should print out "Ok" when the iPhone connects to the server. I also added a sleep() command to the iphone side, so after it connects to the server, it sends some data and then sleeps for 5 seconds. But, on the java side, all of the data, including the "Ok" and the data gets printed out AFTER the sleep command. So its like the iphone isn't connecting until after the program execution is over. Can someone please help me? Thanks...

+1  A: 

AsyncSocket is meant to be fire and forget. You are not supposed to wait for anything to happen. The whole purpose of this class is to do its thing in the background and then notify you when it is done.
If you need a blocking socket then you should use something else.

Romain Hippeau