in reply to Very basic socket question

Hi,

As aukjan said, take a look at IO::Socket::INET.

A small example:

use strict; use warnings; use IO::Socket::INET; use Socket qw(:DEFAULT :crlf); $|++; my $hostname = 'localhost'; my $port = 2001; my $sock = IO::Socket::INET->new(PeerAddr => $hostname, PeerPort => $port, Proto => 'tcp') or die "Can't connect: $!"; $sock->autoflush(1); print $sock "Hello, World!$CRLF"; # Using $CRLF is more portable close $sock;

Hope it give you an idea

Regards,

:-)

Replies are listed 'Best First'.
Re^2: Very basic socket question
by blazar (Canon) on Jun 29, 2005 at 12:38 UTC
    Thank you! Indeed reading the documentation for IO::Socket I noticed that it gives an example with IO::Socket::INET.

    The fact that you suggest yourself that $CRLF is more portable is one of the reasons I asked in the first place, because I suspected that for a complete newbie there may have been some quirks that more experienced users would have been possibly more familiar with.