How to set tcp_nodelay in GCDAsyncsocket?

Solutions Collect From Internet About “How to set tcp_nodelay in GCDAsyncsocket?”

I haven’t used GCDAsyncSocket, but “GCDAsyncSocket.h” shows that you can get the underlying socket descriptor with the socketFD method, which must be called only in a performBlock: call. So the following code might work:

[asyncSocket performBlock:^{
    int fd = [asyncSocket socketFD];
    int on = 1;
    if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof(on)) == -1) {
        /* handle error */
    }
}];

You might have to add

#include <netinet/tcp.h>
#include <netinet/in.h>

to your source file to compile this. As I said, I haven’t tried this, but perhaps it helps to point you in the right direction.