[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK6E8=dnYBLQm4eDh4HOeN_O8uRy8Gvf=PeuT69+6rycjRwRfg@mail.gmail.com>
Date: Fri, 23 Mar 2012 12:03:36 -0700
From: Yuchung Cheng <ycheng@...gle.com>
To: Vincent Li <vincent.mc.li@...il.com>
Cc: Eric Dumazet <eric.dumazet@...il.com>, netdev@...r.kernel.org
Subject: Re: Piggyback the final ACK of the three way TCP connection
establishment with the data
Hi Vincent
On Fri, Mar 23, 2012 at 8:38 AM, Vincent Li <vincent.mc.li@...il.com> wrote:
> On Thu, Mar 22, 2012 at 4:17 PM, Eric Dumazet <eric.dumazet@...il.com> wrote:
>> On Thu, 2012-03-22 at 16:13 -0700, Eric Dumazet wrote:
>>
>>> A third possibility (reading the code) if you use non blocking IO, is to
>>> send() a message right after connect()
>>>
>>>
>>
>> Or use the auto connect on sendto() more probably...
>>
>> That combines the connect() and send()
>>
>
> thanks,
>
> I got the TCP_QUICKACK working, but not the non blocking IO,
> basically, what I did is
>
> if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0){
> perror("Can't create TCP socket");
> return 0;
> }
>
> val = Fcntl(sock, F_GETFL, 0);
> Fcntl(sock, F_SETFL, val | O_NONBLOCK);
>
>
> ip = get_ip(host);
> fprintf(stderr, "IP is %s\n", ip);
> remote = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in *));
> remote->sin_family = AF_INET;
> tmpres = inet_pton(AF_INET, ip, (void *)(&(remote->sin_addr.s_addr)));
> if( tmpres < 0)
> {
> perror("Can't set remote->sin_addr.s_addr");
> return 0;
> }else if(tmpres == 0)
> {
> fprintf(stderr, "%s is not a valid IP address\n", ip);
> return 0;
> }
> remote->sin_port = htons(PORT);
>
> char *query = "GET / HTTP/1.0\r\nHost: 127.0.0.1\r\n\r\n";
>
> tmpres = sendto(sock, query, strlen(query), 0, (struct sockaddr
> *)remote, sizeof(struct sockaddr));
>
> maybe I mis-interpret you.
>
> Vincent
AFAICT the feature that Eric refers to is TCP Fast Open that I am
still testing and have not yet submit to netdev.
But one way to achieve that currently is doing a non-blocking connect
then a blocking write.
I just tried this on 2.6 machine to a remote server
fcntl(sd, F_SETFL, fcntl(sd, F_GETFL, 0) | O_NONBLOCK);
connect(sd, ...);
fcntl(sd, F_SETFL, fcntl(sd, F_GETFL, 0) & ~O_NONBLOCK);
sendto(sd, buf, buf, 0, ...);
The key is that the socket has to be in progress of connecting
when application calls write/sendto(2). If you are testing on loopback,
the connect might finish before sendto so this won't work.
HTH
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists