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. Advertising

  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. Advertising

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:
    459
    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:
    299
    =?Utf-8?B?TmF0aGFuIEJyYWR5?=
    Mar 1, 2005
  3. Guilherme Pinto
    Replies:
    1
    Views:
    314
    Victor Bazarov
    Oct 10, 2003
  4. Berteun Damman
    Replies:
    4
    Views:
    257
    Berteun Damman
    Feb 8, 2008
  5. Replies:
    2
    Views:
    297
Loading...

Share This Page