tags:

views:

24

answers:

1

Hey I am making server client system with asyncsocket class for cocoa, I really don't get it, do I have to send a message to the server in order to receive something, it seems so. Server should send me a message when I connect, but I won't get anything unless I send the server a message which goes pretty strange, same applies, I have to send another message to get a message?

Here is server code, as you see it should send a message when someone connects, which it doesn't do unless I send it a message from client. See code for server

Here is code for client where I send two messages to receive messages from the server. See client code here: http:://pastebin.com/1B7qy9R2 remove other : from link as it's my first post so no 2 link allowed :(

I either have understood the asyncsocket wrongly or there is a bug, but if someone would help it would be appericiated.

A: 

You don’t have to send data before you can receive some. This happens in your code, because you are only calling readDataWithTimeout:tag: in your onSocket:didWriteDataWithTag: delegate method.

Sven
Thanks! Is there any way I can put it into a state that it will read the data constantly?
Samuli