in reply to IO::Socket

Number 1 - use strict!!

That being said - your constuctor for your server socket needs a little tweaking - you don't need to specify LocalAddr. Try this instead:

my $sock = new IO::Socket::INET( LocalPort => 1200, Reuse => 1, Listen => 10, Type => SOCK_STREAM );

UPDATE: I used an IP address for the PeerAddr attribute/key in the client and everything worked fine. I tried localhost, 127.0.0.1, my IP address, and my host name, short and fully qualified and had no problems.

Jeff

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)

Replies are listed 'Best First'.
Re: Re: IO::Socket
by dsb (Chaplain) on Feb 07, 2001 at 19:59 UTC
    And in the client, where is the IP of the remote host specified? I tried to put in the PeerAddr attribute but it didn't work. - kel -
      Your server, by definition listens on the local machine. By giving it a hostname or IP address to listen on, you are telling it that it needs to use its "ears" on that particular hostname/IP, and only listen for connections with that as their destination. Thus, if you use "localhost", only clients on the local machine will be able to connect to the server process, and even then only if they are making their connection to "localhost" or 127.0.0.1.

      All machines with an IP stack usually have at least two IP addresses associated with it: The normal IP address that you use to make connections to the machine from other hosts, and a loopback address 127.0.0.1, which by definition refers to the "local host". The LocalAddr option does not mean "listen for connections coming from clients on the given host", it means "listen for connections from clients connecting *to* the given host, which is this machine". It will fail if the hostname or IP address you give it is not a valid IP address for the host the server is running on.

      So generally, omit the LocalAddr option unless you have an explicit need to only listen on a single interface, ignoring connection attempts being made to other interfaces on the same host. Omitting it is the same as using a LocalAddr of 0.0.0.0, or a wildcard IP, meaning it'll accept connections on all local interfaces, which is usually what you want.

      Does this make sense? I'd also check out the documentation for bind, as this is how LocalAddr is implemented. That might give you some more detail.

        Yeah, that makes alot of sense. I guess I didn't word my question properly though. What I am asking is how do I specify and IP to connect *to* in the client socket script? That is where I am having trouble. The server script runs fine. I did take the LocalAddr attribute out and it still makes the connection and listens. Everything is fine there. The client is the problem. The connection consistently fails unless I put it on the same machine as the server and specify 'localhost' in the PeerAddr attribute. - kel -