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
|