I am trying to verifying that my setting of TCP_NODELAY is working by reading it back after I set it.
Im setting the value to '1', but when I read it back, its set to '4'. Im afraid im doing something wrong.
Heres my code:
int tcpBefore;
socklen_t tcpBeforeLen = sizeof(tcpBefore);
int res = getsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &tcpBefore, &tcpBeforeLen);
// Turn on TCP no delay
int tcpNoDelay = 1;
res = setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, (void *)&tcpNoDelay, sizeof(tcpNoDelay));
int tcpAfter;
socklen_t tcpAfterLen = sizeof(tcpAfter);
res = getsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &tcpAfter, &tcpAfterLen);
The value I get for 'tcpBefore' is '0'. The value I get after I set it is '4'. This seems odd.
Is there something I am doing wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire