Basically I write an NSData object:

[asyncSocket writeData:JSONRequestData withTimeout:-1 tag:1];

Which when run, invokes the delegate

- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag

But for some reason, when the write goes to the buffer... it's not written out to the server.

When I stop my build, I guess the socket decides to write everything and the server ends up seeing it.

How would I fix this? There's no way to flush a CocoaAsyncSocket since it's not necessary... I've tried adding line endings, like "/n" and all, but that doesn't do anything either.

有帮助吗?

解决方案

This is based on user523234's suggestion.

Basically the NSData that you're writing out needs to have some kind of signal to tell the socket that no more data will be coming in.

I appended

[GCDAsyncSocket CRLFData];

to the NSData object

Note: to use the

appendData:

Method, you must convert NSData to NSMutableData.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top