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

Hi there. I'm trying to set up a server/client. For now, all I want is for the server to acknowledge the client and send a message. The server won't work. So far I have:
#!/usr/bin/env perl use IO::Socket; my $SOCK; $SOCK = new IO::Socket::INET ( LocalHost => 'node01', LocalPort => 9000, Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Socket creation failed ..." unless $SOCK; ...
And it dies at that point. I have tried reading through the debugger output but have no idea what to look for. $SOCK is undef by the end. Thanks!

Replies are listed 'Best First'.
Re: Socket newbie: help with host setup
by Corion (Patriarch) on Oct 13, 2010 at 20:10 UTC

    It might be better to give a more verbose error message using $!:

    my $SOCK = IO::Socket::INET->new( LocalHost => 'node01', LocalPort => 9000, Proto => 'tcp', Listen => 1, Reuse => 1, ) or die "Socket creation failed: $!";
Re: Socket newbie: help with host setup
by kcott (Archbishop) on Oct 14, 2010 at 07:16 UTC

    The perlipc manpage has information you'll probably find useful. The sections TCP Clients with IO::Socket, TCP Servers with IO::Socket and maybe Sockets: Client/Server Communication would appear to be the most pertinent.

    -- Ken