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

Hi, I am new to Sockets in perl and I am trying to use a legacy script in Linux. I start a local server on a machine using the command below , $SERVER = IO::Socket::INET->new( Proto => 'tcp', LocalAddr => "$LOCAL_STATION", LocalPort => "$SOCKET_PORT_2ND", Listen => SOMAXCONN, Reuse => 1) On the other machine I try to connect using the below command by giving the correct server name and port no $RUN_STATION_SERVER = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => "$SERVER_HOST", PeerPort => "$SOCKET_PORT"); Here I am not able to connect and I am coming out. I am really not sure what is the problem.If the Server and run station is same then I am not seeing an issue. I see that issue is there when there are 2 different machines used.

Replies are listed 'Best First'.
Re: Socket Connection issue
by targetsmart (Curate) on Mar 26, 2009 at 17:51 UTC
    what is in "$LOCAL_STATION" and "$SOCKET_PORT_2ND" if "$LOCAL_STATION" is localhost or something similar(127.0.0.1) then client won't be able to connect from a different machine.
    check with 0.0.0.0 in "$LOCAL_STATION"

    if you want to check your socket server use plain telnet as a client(before complaining about client).
    you can use netcat(unix) command also as server to check client if client is proper and has no connection issues.
    see Markup in the Monastery before putting code


    Vivek
    -- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
Re: Socket Connection issue
by ig (Vicar) on Mar 28, 2009 at 23:20 UTC

    There are examples of working client and server code based on IO::Socket in perlipc.