Operating System - HP-UX
1827838 Members
1641 Online
109969 Solutions
New Discussion

Re: send() function sleeping for tcp socket

 
joeyu1201
Occasional Advisor

send() function sleeping for tcp socket

I have a tcp server application to generate reqeust and send to client. However, after startup a while, the application is blocked by send() function.

$ truss -p 10591
( Attached to process 10591 ("J_SMPP_Handler 127.0.0.1") [64-bit] )
send(5, 0x9ffffffffff97d60, 59, 0) [sleeping]

Why does send() being blocked?
7 REPLIES 7
Steven Schweda
Honored Contributor

Re: send() function sleeping for tcp socket

> I have a tcp server application [...]

Running on what, exactly? (_Who_ has
"truss"?)

Getting an accurate diagnosis of invisible
code running on a mystery system may be more
difficult than you seem to think.
joeyu1201
Occasional Advisor

Re: send() function sleeping for tcp socket

The application is running on IA64 11.31
joeyu1201
Occasional Advisor

Re: send() function sleeping for tcp socket

I call send with following parameter:
rc = send(fd, (char*)buffer, byte_to_send, 0);
James R. Ferguson
Acclaimed Contributor

Re: send() function sleeping for tcp socket

Hi:

What does the return value of 'send()' contain? The manpages for 'send(2)' describe the various expectations including potential 'errno' indicators.

Regards!

...JRF...
Matti_Kurkela
Honored Contributor

Re: send() function sleeping for tcp socket

Maybe the client isn't reading from it's socket buffer for some reason.

As the client's receive buffer fills up, the client OS will automatically send TCP options to inform your server about the shrinking available space in the client's TCP receive window. Once the receive buffer has been completely filled, the TCP window size will also be reduced to zero.

At that point, the server knows it cannot send anything more to the client until the client processes the data already sent. As no more data can be sent, any further data will remain in the server socket's transmit buffer until the client sends another message telling it can receive more. Once the server socket's transmit buffer is 100% full, the send() function will start blocking.

From the send(2) man page:
----
If no buffer space is available to hold the data to be transmitted, send() blocks unless nonblocking mode is enabled.
----
... and if you had enabled nonblocking mode, the send() function would have failed with errno set to either EAGAIN or EWOULDBLOCK.

MK
MK
joeyu1201
Occasional Advisor

Re: send() function sleeping for tcp socket

Can I know the remaining available TCP buffer of client/server side?
I used netstat to view the socket buffer, but there is accumulated data in socket buffer.
joeyu1201
Occasional Advisor

Re: send() function sleeping for tcp socket

sorry, should be no accumulated data in socket buffer