Distinguishing between socket buffer full & socket disconnected

J

John Ramsden

I am using the IO::Select method can_write() to flow control the writing
of a large amount of data to a socket, where the writer may well run ahead
of the receiver at the other end and thus cause the local buffer to become
full.

I gather the can_write() method takes care of that, by only returning
true when the outgoing buffer is not full. But how does one distinguish
this from the situation where the remote process has closed its end of
the socket connection?

I'm happy to set a large timeout for can_write(), and call it in a loop,
while the connection is open and the receiver will sooner or later get
round to reading its end of the socket and thereby clear the log jam.

But obviously the sender will loop forever if can_write() is returning
false because the receiver process has packed up and gone home!


Cheers

John Ramsden ([email protected])
 
B

Brian McCauley

I am using the IO::Select method can_write() to flow control the writing
of a large amount of data to a socket, where the writer may well run ahead
of the receiver at the other end and thus cause the local buffer to become
full.

I gather the can_write() method takes care of that, by only returning
true when the outgoing buffer is not full. But how does one distinguish
this from the situation where the remote process has closed its end of
the socket connection?

I think has_exception() is true for such handles.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top