Question : recur send return -1 with EWOULDBLOCK errno

I have an application in SCO5 communicated with several machines using nonblocking sockets with TCP_NODELAY. Once in a while, it has one socket repeatly send return with EWOULDBLOCK and select detect it writeable and send again. The send will try several times to thousands of time when the traffic is busy. It always happened in the same machine that talks to my application, not others.

Normally it is okay to return EWOULDBLOCK. But it doesn't look right if send has to try thousands of time until it sends out the message. The messages are all less than 512 bytes.

I checked the kernel parameters and all of the machines are similar.

Any idea?

Thanks.

Tao

Answer : recur send return -1 with EWOULDBLOCK errno

In any case, seems that the problem is in "kernel buffer saturation". Try to analyze the incoming/outgoing traffic
of the problematic station.

If you use simple hub, try to move to a switch.

A solution may be like this:
  if send() failed on EWOULDBLOCK/EAGAIN for at least
100 times, warn in the log, set this socket to blocking mode, send your packet, unset blocking and continue.
Actually, man pages have no comments/recommendations
what to do in this case (EWOULDBLOCK/EAGAIN).

Also, since you use select(), you can try not using non-blocking option.
Random Solutions  
 
programming4us programming4us