in reply to Networking with Perl

It sounds like you might be a little confused on the networking thing. When a client connects to your server, you accept the socket and store a reference to that socket in a variable. You can then access that socket any time you want, to read or write, via the variable. You never need to worry about the port again.

Once you have accepted the connection, you can go back to listening on the original port - the kernel takes care of all the details. So everytime you accept a connection, you can just add the socket to an array or a hash, and keep track of them like any other variable.

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Re: Networking with Perl
by gri6507 (Deacon) on Sep 06, 2002 at 15:24 UTC
    What you are saying is true. However, following my original example, 5 connections will still mean 11 open sockets at all times. I was looking to do it somehow else. Maybe, for example, have a single method that would send a string to a particular IP adress / port number of a particular client, thus illiminating the need for at least 5, or maybe even 10 of those 11 sockets.
      However, following my original example, 5 connections will still mean 11 open sockets at all times.

      So don't follow your original example.

      I was looking to do it somehow else.

      I told you how to do it 'somehow else'. I don't get it. You ignored what I wrote, then demanded the answer I gave you, while insisting on continuing on doing it the wrong way. Do you work for MicroSoft?

      Pay attention this time:

      • Sockets are bidirectional. YOU DO NOT NEED TWO PER CONNECTION.
      • You don't need to manage ports. The kernel does it for you already. STOP DOING IT YOURSELF.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.