in reply to Re: IO::Select and sockets
in thread IO::Select and sockets

I have found can_read to be rather useless in practice. can_read allows one to read from sockets without blocking, but one usually needs to also write to sockets without blocking. The select method does that.

Replies are listed 'Best First'.
Re^3: IO::Select and sockets
by runrig (Abbot) on Dec 29, 2005 at 18:36 UTC
    I think it depends whether you're connecting to a service, or creating a service and waiting for connections to it. If I need to do both at the same time, then I'd probably use select(), otherwise, I'll use a can_* method (or maybe I'm missing something and doing it inherently wrong?).

      Any servers that handles mutliple connections must

      • Wait to read incomming connections from the server socket.
      • Wait to read incomming requests from each client socket from which a request hasn't been obtained.
      • Wait to write reponses to each client socket from which a request has been obtained.
      • Wait for errors.

      All of these can occur at the same time, which is why can_* are insufficient, and select is desired on the server side.

       

      Any clients that handles mutliple connections must

      • Wait to write requests to every server socket to which a request has not been sent.
      • Wait to read incomming responses from each server socket to which a request has been sent.
      • Wait for errors.

      All of these can occur at the same time, which is why can_* are insufficient, and select is desired on the client side.