Hi all
I'm a newbie on perl programming and i need to create a tcp socket connection
my code is below and my problem is that i can't print the message from the client ($_)
#!/usr/bin/perl
use IO::Socket::INET;
my $my_server = 'whatever';
my $my_proto = 'tcp';
my $my_port = '1234';
my $my_listen = 1;
my $my_reuse = 1;
my $sock = IO::Socket::INET->new( LocalHost => $my_server,
LocalPort => $my_port,
Proto => $my_proto,
Listen => $my_listen,
Reuse => $my_reuse
);
die "Can't stablish connection with the socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while(defined(<$new_sock>))
{
print $_;
}
close $sock;
Happy coding!!!
José García Sabbagh
México D.F.
I'm a newbie on perl programming and i need to create a tcp socket connection
my code is below and my problem is that i can't print the message from the client ($_)
#!/usr/bin/perl
use IO::Socket::INET;
my $my_server = 'whatever';
my $my_proto = 'tcp';
my $my_port = '1234';
my $my_listen = 1;
my $my_reuse = 1;
my $sock = IO::Socket::INET->new( LocalHost => $my_server,
LocalPort => $my_port,
Proto => $my_proto,
Listen => $my_listen,
Reuse => $my_reuse
);
die "Can't stablish connection with the socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while(defined(<$new_sock>))
{
print $_;
}
close $sock;
Happy coding!!!
José García Sabbagh
México D.F.