TCP_CORK (aka TCP_NOPUSH) does not work
Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
cygwin@cygwin.com
Tue Jul 30 21:30:00 GMT 2019
Hi,
Consider the following code:
$ cat cork.c
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#if defined(TCP_NOPUSH) && !defined(TCP_CORK)
# define TCP_CORK TCP_NOPUSH
#endif
int main(int argc, const char* argv[])
{
union {
struct sockaddr_in in;
struct sockaddr sa;
} addr;
int sock, cork = 1;
memset(&addr, 0, sizeof(addr));
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror("socket");
addr.in.sin_family = AF_INET;
addr.in.sin_addr.s_addr = inet_addr(argv[1]);
addr.in.sin_port = htons((unsigned short) atoi(argv[2]));
if (connect(sock, &addr.sa, sizeof(addr.in)) < 0)
perror("connect");
if (setsockopt(sock, IPPROTO_TCP, TCP_CORK, (char*) &cork, sizeof(cork)) != 0)
perror("cork");
return 0;
}
When compiled and run under Cygwin, the last syscall, setsockopt(), returns an error, Protocol not available:
gcc cork.c
./a.exe 8.8.8.8 443
cork: Protocol not available
The same code works under Linux just fine. I straced both.
gcc cork.c
./a.out 8.8.8.8 443
Any ideas? Is TCP_NOPUSH (which is a BSDism, BTW) not actually usable on Cygwin? If not, why is it in the header file <netinet/tcp.h>?
TIA!
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list