Im having problem with this
the error is on the receiver
cannot print sockets
"Use of uninitialized value in print at D:\re.pl line 18, <GEN1> line 1."
please help me
#!perl -w
# sender
use IO::Socket;
&comunicate;
sub comunicate {
print "Mes :";
my $message = <STDIN>;
chomp $message;
my $sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => '7070',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "$message\n";
close($sock);
&comunicate;
}
# note has to be broken
# end sender
#!perl -w
# receiver
use IO::Socket;
my $sock = new IO::Socket::INET (
LocalHost => 'localhost',
LocalPort => '7070',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while(defined(<$new_sock>)) {
print $_;
}
close($sock); Knowledge is the first step to Greatness!!!
the error is on the receiver
cannot print sockets
"Use of uninitialized value in print at D:\re.pl line 18, <GEN1> line 1."
please help me
#!perl -w
# sender
use IO::Socket;
&comunicate;
sub comunicate {
print "Mes :";
my $message = <STDIN>;
chomp $message;
my $sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => '7070',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "$message\n";
close($sock);
&comunicate;
}
# note has to be broken
# end sender
#!perl -w
# receiver
use IO::Socket;
my $sock = new IO::Socket::INET (
LocalHost => 'localhost',
LocalPort => '7070',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while(defined(<$new_sock>)) {
print $_;
}
close($sock); Knowledge is the first step to Greatness!!!