Adonnai has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to not block when connecting to an address with IO::Socket::INET? If not how else can I go about initiating a socket connection but not waiting for the actual connection occur (so I can come back to it later and handle it).

Replies are listed 'Best First'.
RE: Not blocking on a socket connect
by Shendal (Hermit) on May 26, 2000 at 22:45 UTC
    It is unclear to me if you are listening to the port, or attempting to connect to one.

    As a listening process, you can use fork() to launch child processes to handle individual connections. This is described well in O'Reilly's Advanced Perl Programming (p. 193 - Handling Multiple Clients).

    In the same chapter, the authors go on to describe multiplexing using Select. This is useful if you are waiting on any one of a set of connections to occur, and then handle appropriately.

    Can you provide more detail on why you don't want to wait on a connection? Is spawning of a child process not acceptable for some reason?
      Sorry for the ambiguity...
      I want to make a connection to a remote host with me being the client. The problem is that I need to handle other tasks while I wait for the connection to occur (i.e. create socket, initiate connection, do something else, check connection status). I don't want to be stuck waiting for connect() to return. I know I could fork to do concurrent stuff but I'm just curious as to if it's possible.
        Yeh yeh, I also need to know this exact thing .... please answer, I'm well stuck! Cheers, -Be