[HELP] About tcp_poll(...) for Linux TCP
From: kevin (kthkevin_at_gmail.com)
Date: 09/14/05
- Next message: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Previous message: Madhav: "Error while starting a program in GDB"
- Next in thread: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Reply: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Previous message: Madhav: "Error while starting a program in GDB"
- Next in thread: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Reply: David Schwartz: "Re: [HELP] About tcp_poll(...) for Linux TCP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|