Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - socket send call getting blocked for so long: (5 Items)
   
socket send call getting blocked for so long  
Hi,

Currently we're developing software on QNX for automotive.
I'm using sockets to communicate with another linux machine.
These two machines are installed into one unit and wired through an USB-ethernet interface.

Now I have an issue that send() is taking too long (about over 30 seconds) to return.
I found out that becoming full of TCP buffer is one of the cause, but they aren't sending so much data, i think.
Therefore, i'd like to know if there're other reasons causing this issue.

I guess that closing the tx socket from another thread at the same time with send() caused my issue,
but can't explain it clearly.

Please tell me your ideas.

Thanks a lot for your support.

Best Regards,
D.X.Quoc
Re: socket send call getting blocked for so long  
With TCP once the socket buffers are full then you will be limited by the speed that the far end is reading from the 
socket.

One alternative would be to use a non-blocking socket and then select() on it to tell if there is room to write, that 
would prevent you from being blocked on the socket.
Re: socket send call getting blocked for so long  
> With TCP once the socket buffers are full then you will be limited by the 
> speed that the far end is reading from the socket.
> 
> One alternative would be to use a non-blocking socket and then select() on it 
> to tell if there is room to write, that would prevent you from being blocked 
> on the socket.

Hi Nick Reilly,
Thanks for your reply.

I'm using SO_SNDTIMEO to shorten the wait time.
But i still need to know if there are other causes, besides full socket buffers.
Is it right if i think there's not anything else?

Best Regards,
D.X.Quoc
Re: socket send call getting blocked for so long  
The send buffer is full, that is blocking the write. It will fill up because it isn't receiving ACKs for the receive 
side. This could be because the network path between the two has gone down, or it could be because the reader on the 
receive side isn't reading fast enough. But fundamentally what blocks the write is the full Tx socket buffer.

Regards,
Nick.
Re: socket send call getting blocked for so long  
> The send buffer is full, that is blocking the write. It will fill up because 
> it isn't receiving ACKs for the receive side. This could be because the 
> network path between the two has gone down, or it could be because the reader 
> on the receive side isn't reading fast enough. But fundamentally what blocks 
> the write is the full Tx socket buffer.
> 
> Regards,
> Nick.

Hi Nick,

So, i'll check the send buffers.
Thank you very much for your support.

Best Regards,
D.X.Quoc