public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin" <cygwin@cygwin.com>
To: "'cygwin@cygwin.com'" <cygwin@cygwin.com>
Subject: TCP_CORK (aka TCP_NOPUSH) does not work
Date: Tue, 30 Jul 2019 21:30:00 -0000	[thread overview]
Message-ID: <BL0PR0901MB43089F348C3D31D7E07EBC20A5DC0@BL0PR0901MB4308.namprd09.prod.outlook.com> (raw)

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

             reply	other threads:[~2019-07-30 21:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 21:30 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin [this message]
2019-07-31  3:50 ` Brian Inglis
2019-07-31  4:49 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-07-31 19:32 ` Brian Inglis
2019-07-31 21:00 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-07-31 22:11 ` Ken Brown
2019-07-31 23:16 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BL0PR0901MB43089F348C3D31D7E07EBC20A5DC0@BL0PR0901MB4308.namprd09.prod.outlook.com \
    --to=cygwin@cygwin.com \
    --cc=lavr@ncbi.nlm.nih.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).