in reply to Seeking explanation of IO::Socket behaviour

The "# never reach here" line is reached on the parent process when the input stream reaches EOF (which might involve typing ^D if the input stream is the terminal). Assuming that "# never reach here" is the end of the script, falling past it implicitly closes the socket from the parent side, which will cause the child process to see EOF on the socket. The child then hits the "# never reach here" line.

Unless I'm missing some subtle point, the "# never reach here" comment is a lie.

  • Comment on Re: Seeking explanation of IO::Socket behaviour

Replies are listed 'Best First'.
Re: Re: Seeking explanation of IO::Socket behaviour
by graff (Chancellor) on Apr 22, 2002 at 03:08 UTC
    I don't think dws missed anything, but the Anonymous Monk forgot to mention: what is being fed to the parent's stdin? If this is run from the command line without (redirection from) a file name, and without a preceding pipeline process, it will run endlessly until the person who entered the command has the presence of mind to type in data, then type in "^D" (on unix) or "^Z" (on dos/windows) to signal the end of stdin.
      Thanks for your wisdom. I really needed to know if the program will run indefinitely. Now I know it will. Thanks again.
Re: Re: Seeking explanation of IO::Socket behaviour
by Anonymous Monk on Apr 22, 2002 at 03:27 UTC
    Thanks for that piece of wisdom. It's a big help.