开发者

socket send part down but receive part Up , possible?

I am wondering if it is possible to have a socket with send which doens't work (because buffer of peer is full maybe) while receive part still working开发者_开发问答 ?

EDIT:

In case of a peer which doesn't perform a half close connection, and which it is too long to process its receive buffer (so its receive buffer is full), can I have an error only on my send part ?


You can have a socket through which you can't send if you close your side of the connection (half-closed connection). You can do that with shutdown(2). When you half-close the connection in this way you're saying "I don't have anything else to say, but if you send be stuff I'll look at it".

The buffer on the other side should make no difference. When you send something, you don't put it in the buffer of your peer. You put it in a buffer in your kernel, and the kernel later sends it to the peer.

There is little chance of having a working connection and filling your buffers to the point you get errors from send(2).


Short answer: yes. If remote peer receives data at a slow rate (possibly due to slow data processing between recv calls) it will slow down transmission at a sending side: ACKs will be coming slowly and sending buffer will quickly get full which will cause your socket send operation to block or return error. On the other hand, as TCP is bidirectional protocol and TCP stack uses different kernel buffer for receiving data, local peer can still receive data sent from remote peer.


Of course it is possible. For example, if you have unix domain socket and no one is reading from it.If you are asking about TCP or UDP sockets, the answer could be more complicated

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜