Distinguishing between socket buffer full & socket disconnected

Discussion in 'Perl Misc' started by John Ramsden, Aug 5, 2003.

  1. John Ramsden

    John Ramsden Guest

    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 ()
     
    John Ramsden, Aug 5, 2003
    #1
    1. Advertisements

  2. (John Ramsden) writes:

    > 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\\
     
    Brian McCauley, Aug 5, 2003
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maziar Aflatoun
    Replies:
    2
    Views:
    615
    Greg Burns
    Sep 13, 2004
  2. =?Utf-8?B?TmF0aGFuIEJyYWR5?=

    Distinguishing Between IE Windows

    =?Utf-8?B?TmF0aGFuIEJyYWR5?=, Feb 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    376
    =?Utf-8?B?TmF0aGFuIEJyYWR5?=
    Mar 1, 2005
  3. Jarle Jacobsen
    Replies:
    3
    Views:
    27,678
    Jarle Jacobsen
    Aug 31, 2004
  4. Guilherme Pinto
    Replies:
    1
    Views:
    435
    Victor Bazarov
    Oct 10, 2003
  5. Berteun Damman
    Replies:
    4
    Views:
    411
    Berteun Damman
    Feb 8, 2008
  6. Replies:
    2
    Views:
    421
  7. Jason Kristoff

    How do I reconnect a disconnected socket?

    Jason Kristoff, Mar 28, 2008, in forum: Python
    Replies:
    7
    Views:
    760
    Bryan Olson
    Mar 29, 2008
  8. laredotornado
    Replies:
    2
    Views:
    988
    laredotornado
    Dec 4, 2009
Loading...