Operating System - HP-UX
1833530 Members
3027 Online
110061 Solutions
New Discussion

TCP Send returns 0 bytes in HP UX 11.0

 
SOLVED
Go to solution
Kent Chow
Advisor

TCP Send returns 0 bytes in HP UX 11.0

Hi:

Under heavy network and using
tcp sockets in HP UX 11.0.
Repeatedly calls using sendto,
occasionally will return 0 bytes, but have no errors.
Has anyone experience this problem and what can one do to remedy the problem?

Thanks in advanced.


1 REPLY 1
Steven Gillard_2
Honored Contributor
Solution

Re: TCP Send returns 0 bytes in HP UX 11.0

This is normal behaviour when you are using non-blocking sockets. Simply, it means the network layer is not able to transmit the data at the rate the application is sending it, hence the socket's send buffer has filled up. Here is the relevant section from the send(2) man page:

"If the O_NDELAY flag is set using fcntl() (defined in and explained in fcntl(2) and fcntl(5) ), nonblocking I/O is enabled. In this case, the send() request completes in one of three ways:

If there is enough space available in the system to buffer all of the data, send() completes successfully, having written out all of the data, and returns the number of bytes written.


If there is not enough space in the buffer to write out the entire request, send() completes successfully, having written as much data as possible, and returns the number of bytes it was able to write.


If there is no space in the system to buffer any of the data, send() completes successfully, having written no data, and returns 0. "


You have a couple of choices in handling this:

- use select() to find out when the socket is once again ready for writing

- don't use non-blocking sockets so that the send() call will block until all data is sent.

Regards,
Steve