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

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: same port
by sacked (Hermit) on Jul 08, 2004 at 23:02 UTC
    Did you try?
    zackse@augustus:/tmp$ perl server.pl & zackse@augustus:/tmp$ perl proxy.pl Cannot initialize proxy daemon: Address already in use at /usr/lib/perl5/site_perl/5.8.0/HTTP/Proxy.pm line 461

    --sacked
Re: same port
by beable (Friar) on Jul 08, 2004 at 23:05 UTC
    Did you try it? I think you'll get an error that the port is already in use. This makes sense, because what do you think would happen with two servers listening on the same port? Which one should get the packets sent to that port? Should they fight it out with a game of Rock Paper Scissors to decide?

      Actually not germane to the original question, but you can have multiple processes listening on the same port. Perhaps the most familiar instance of this would be apache where each of the child httpds can have a copy of the same socket descriptor (and use a locking mechanism on some OSen (older Solaris in particular) where multiple processes calling accept isn't handled correctly). Hypothetically you could have intelligence enough in each server process to determine what protocol was being spoken and do a file descriptor send (aka deep POSIX IPC wizardry) to another process if the one that received the connection can't handle it, but I can't think of any practical benefit to doing so.

A reply falls below the community's threshold of quality. You may see it by logging in.