in reply to Re: Re: Re: IO::Socket
in thread IO::Socket

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 -

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: IO::Socket
by Fastolfe (Vicar) on Feb 08, 2001 at 00:01 UTC
    The client needs to make use of the PeerAddr field in your IO::Socket::INET constructor, or via the object's connect call. Any valid IP/hostname for the server should work fine. Note that IO::Socket reports its errors in $@, not $!, so printing out the value of this variable may be helpful in identifying the problem. There's no reason this shouldn't work, unless the problem is external (firewall or network), or if you're using an invalid hostname/IP.
      Okay. This is the code I am using to create the client socket. I have tried the PeerAddr with both a 4 byte IP number, and the domain name and nothing has worked. It dies with the IP, and it hangs with the domain.
      $sock = new IO::Socket::INET( PeerAddr => 'dev01.nerds.com', PeerPort => 1200, Proto => 'tcp', Type => SOCK_STREAM );
      What am I doing wrong? I am at a total loss. - kel -
        Try connecting to the server program with telnet from the machine where you're running the client program. % telnet dev01.nerds.com 1200 If that doesn't work, then the problem probably isn't in your client program.

        Well, if you still have LocalAddr=>'localhost', then the above won't connect because the server won't be listening at the address you are trying to connect via.

        As kschwab pointed out, using LocalAddr in a server is almost always a mistake (and it is a very common mistake).

                - tye (but my friends call me "Tye")