[HELP] About tcp_poll(...) for Linux TCP

From: kevin (kthkevin_at_gmail.com)
Date: 09/14/05


Date: 14 Sep 2005 04:38:09 -0700

Hi all:

When I read /net/ipv4/tcp.c, I found this tcp_poll which is used to
wait for some event for the socket, but I failed to find some code
about how to use this function.

For example, if I want to send some data via TCP socket, for each
send(...) TCP will do tcp_wait_for_wmem(...) to wait until the buffer
is writable, if timeout is expired, some error code will return, then I
can catch the error and re-send the buffer if possible.

I have tried this with another TCP stack on OSE DELTA, the code seems
like this:

struct pollfd fds[1];
fds[0].fd=mySocketID;
fds[0].events=POLLOUT; // set the event to listen

WHILE(...)
{
int noOfBytes=send(mySocketID, buf, len, 0);
if (noOfBytes==-1)
{
    if(errno==EAGAIN) // the send buffer is full, can not send for this
moment
     {
        tcp_poll(fds,0,TIMEOUT) // return when POLLOUT occures or
TIMEOUT expires, otherwise exit
        continue; // continue sending data
     }
    else
       EXIT;
}
...
}

And I wonder how to do the same things for LINUX/TCP, and is it true
that there is no TIMEOUT for LINUX/TCP polling?

thanks!

br

/kevin



Relevant Pages

  • [HELP] About tcp_poll(...) on Linux TCP
    ... For example, if I want to send some data via TCP socket, for each ... TIMEOUT expires, otherwise exit ... that there is no TIMEOUT for LINUX/TCP polling? ...
    (comp.os.linux.networking)
  • Re: No error while sending via TCP Socket
    ... I have been looking through Volume 1 & 2 on the topics of TCP ... Retransmission" where you talk about round trip times. ... you would be what would make a tcp connection timeout? ... TCP will not let you know that the socket is down until you try to send ...
    (comp.lang.python)
  • Re: IO::Socket::INET on OSX or TCP stack problem
    ... timeout is fine with its default. ... the protocol and type NEVER change if you want a tcp connection ... >> cause of the socket dropouts. ... problem and i am sure many mac coders have written perl socket code for it. ...
    (comp.lang.perl.misc)
  • Re: [HELP] About tcp_poll(...) for Linux TCP
    ... > wait for some event for the socket, but I failed to find some code ... > is writable, if timeout is expired, some error code will return, then I ... > TIMEOUT expires, otherwise exit ... > that there is no TIMEOUT for LINUX/TCP polling? ...
    (comp.os.linux.development.system)
  • Re: How to set socket option SO_RCVTIMEO
    ... hehe yeh I just realized I could use a regular Socket instead of a TCP ... Socket -- it doesn't appear to be the only problem though. ... so we should get a timeout on our socket ...
    (comp.lang.ruby)