iphone - GCDAsyncSocket - not receiving data - AsyncSocket works ok -


i made iphone client connect server using gcdasyncsocket. server running .net on windows server. connect , sends data too.

i tell client go receive directly after send...

[sock readdatatodata:[gcdasyncsocket lfdata] withtimeout:15 tag:1];  

i have set receive:

- (void)onsocket:(gcdasyncsocket *)sock didreaddata:(nsdata *)data  withtag:(long)tag  

and also:

   - (nstimeinterval)socket:(gcdasyncsocket *)sock shouldtimeoutreadwithtag:(long)tag  

if wait time out time out method called.

if send data server, timeout not called, assume client has seen something, there no indication of on client side.

i added:

- (void)socket:(gcdasyncsocket *)sock didreadpartialdataoflength: (nsuinteger)partiallength tag:(long)tag  

hoping see partial packet not triggered either.

as mentioned above timeout not trigger if send server client. have thought timeout if hasn't received terminator character. tried reading length of 3 didnt make difference.

the gcdasyncsocket the problem. asyncsocket seems work ok.

maybe init wrong?

dispatch_queue_t mainqueue = dispatch_get_main_queue();

asyncsocket = [[gcdasyncsocket alloc] initwithdelegate:self delegatequeue:mainqueue]

any ideas did wrong?

i put post on goggle code there isnt activity not sure if answer or not.

ideally if has sample code receives works great! thank you!

maybe there wrong spelling. (so happened me , searching hours until i've seen small difference)

gcdasyncsocket renamed delegate callbacks onsocket socket match apples naming style.

in example above have mentioned

- (void)onsocket:(gcdasyncsocket *)sock didreaddata:(nsdata *)data withtag:(long)tag  

rename to

- (void)socket:(gcdasyncsocket *)sock didreaddata:(nsdata *)data withtag:(long)tag  

this should resolve problem.

and in code i've had problem, too. sure object, calls gcdasyncsocket, still alive while connecting. gcdasyncsockets delegate weak reference object. , because async, delegate can become 0 (autorelease, or instance created inside method left) while socket responding. result appears not called, class started socket deallocated memory. happens if using arc gcdasyncsocket.

hope helps


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -