This is the mail archive of the
cygwin
mailing list for the Cygwin project.
TCP_CORK (aka TCP_NOPUSH) does not work
- From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin" <cygwin at cygwin dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Tue, 30 Jul 2019 21:30:41 +0000
- Subject: TCP_CORK (aka TCP_NOPUSH) does not work
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=ncbi.nlm.nih.gov;dmarc=pass action=none header.from=ncbi.nlm.nih.gov;dkim=pass header.d=ncbi.nlm.nih.gov;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w18N8wq0N2Mj+jwXpts9kz18KTE16Lvq1d4P0s05cbs=; b=jx2r7Nb8RkjmLV04ZSeRdaY+4+IKkKKAAw7PfmjWqX1x6YCHj8dj/M3pmCdJrmZ1Zvv8j7tvBu9IlEMBrSPmXsfRAL5ch+9LQbKWZy5s29jCy+0eFqYVxBXVpFdkt/KalxCtqQlytzZE8YdF/4gRUy9Ze79pFQU5HTKdiz5QqLgRHImWQuPSDZvWq8rM5PAwgBsJzqflIDieAWaArGN0VzIE4zIHBMKAIhr/CSxJysJGERvGRj3f1RP1fIYjAswhyovfskmIHkeUMzy0jerNVhvl67UGVwnLsk5TCBle+7k2YG5fcpK/5g0u6QOzVT6CM2CoyDy4nZFYPkWjC3z/NA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hCiJDtvXniuTgLy/FLtjJEEm+bvnIMGzMRsQnVlzWeeEua+zIDHnB3d2ZycEJNc+HaNB5pX8ZDPQ7iDdNEJg+asRzFXnUjXnf8d4GRRwOFwM8bK3Vc/EFZqGVxzsOIovwvV6bppof9Be2ivxxhpYgOQeowNEnHhNbpkZprCmnGRX34rOoZBzJGhxg3MH7U7fc3rWo6DPBlfi1nCFgU7XPUP69oqmHq2t88VljeEc7QLsOs0Gr6A7zhlPhT+kDA0pIhmAuAhKQHDoUmw4T67nUqwKxly7iczmpTZ8n3R/rxcx3QQ7d5PC/rugswKiFMOndM6KdsmsmJOfiO6R89LVCQ==
- Ironport-sdr: pZwrCxP5F4rE0qZW2UeqG+yXm9SWPAbf0Ob4WnWbKQHzu6K6dBdtluO5yz0GvDuqYeSblob8Ez R4Z0yUI1Vohw==
- Reply-to: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr at ncbi dot nlm dot nih dot gov>
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