T
Tompyna
Hi All,
I am a newbie to Socket Programming . I had written a socket
program in perl , implementing client and server.
Now coming to the problem i am stuck:
1.When i implement the program with "UDP" as protocol option, the code
works
fine,but When i try to implement the same program , giving TCP as
the
protocol option, it gives me an error:
"Can't call method "recv" on an undefined value at servermodulenew.pl
line 18"
I believe the method "recv" should be called irrespective of the
protocol option i give.
Hope someone could possibly give me an answer to this problem.
(Below is the code for server implementation)
NOTE: The program is executing on solaris and run as a background
process.
The server Program i implemented is:
/************************************************/
# Server Program
use IO::Socket;
my $port = 1024;
#use ngd_simulator::thomasp:
erl::Socket;
my $receive_status;
print ">> Server Program <<\n";
# Create a new socket
$MySocket=new IO::Socket::INET->new(LocalPort=>($port),Proto=>(getprotobyname('udp')));
while(1)
{
#Receiving a message from the client
$receive_status = $MySocket->recv($text,128);
if($text ne '')
{
print "\nReceived message ===>", $text,"\n";
}
# If client message is empty exit
else
{
print "Cilent has exited!";
exit 1;
}
}
#Close the Socket after sending the message
close($MySocket);
/******************************************************/
Thanx.... in advance,
Thomas Poly.
I am a newbie to Socket Programming . I had written a socket
program in perl , implementing client and server.
Now coming to the problem i am stuck:
1.When i implement the program with "UDP" as protocol option, the code
works
fine,but When i try to implement the same program , giving TCP as
the
protocol option, it gives me an error:
"Can't call method "recv" on an undefined value at servermodulenew.pl
line 18"
I believe the method "recv" should be called irrespective of the
protocol option i give.
Hope someone could possibly give me an answer to this problem.
(Below is the code for server implementation)
NOTE: The program is executing on solaris and run as a background
process.
The server Program i implemented is:
/************************************************/
# Server Program
use IO::Socket;
my $port = 1024;
#use ngd_simulator::thomasp:
my $receive_status;
print ">> Server Program <<\n";
# Create a new socket
$MySocket=new IO::Socket::INET->new(LocalPort=>($port),Proto=>(getprotobyname('udp')));
while(1)
{
#Receiving a message from the client
$receive_status = $MySocket->recv($text,128);
if($text ne '')
{
print "\nReceived message ===>", $text,"\n";
}
# If client message is empty exit
else
{
print "Cilent has exited!";
exit 1;
}
}
#Close the Socket after sending the message
close($MySocket);
/******************************************************/
Thanx.... in advance,
Thomas Poly.