Hello everyone,
I am stuck in a problem. Its a PERL socket programming problem. This is whats happening.
I have a server that has two sockets. One socket($listen_socket) for listening any incoming request and One socket($sendingSocket) that will send a reply to one client only.(Actually it is a server that will only listen from one client and reply to that client). Here is my code
Code:
$listen_socket = new IO::Socket::INET(LocalHost => 'xxx.xxx.xxx.xxx', LocalPort => xxxx, Proto => 'tcp', Listen => 10, Reuse => 1);
$sendingSocket = new IO::Socket::INET(PeerHost => 'different IP', PeerPort => 'same port as the server', Proto => 'tcp');
while($newSocket = $listen_socket->accept())
{
while($newSocket->recv($data, 10000))
{
print "Data Received : ".$data."\n";
if($sendingSocket eq "")
{
# create sendingSocket again
}
if($sendingSocket->send("11111111"))
{
print "done \n";
}
}
close $newSocket;
}
close $listen_socket;
Now the problem is if client sends any request to server, server receives the first request, and sends a reply... after that it receives an empty msg from client and after that does not receive any request from the client. so when ever i send a reply the listening socket just totally stops listening. why is it happening
Pls reply
Thanks
Mishu