-   Programming (
-   -   creating a sender socket blocks a listening socket (

murahman 09-22-2008 09:14 AM

creating a sender socket blocks a listening socket
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


$listen_socket = new IO::Socket::INET(LocalHost => '',      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
        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


nadroj 09-22-2008 12:11 PM

try and put print statements before and after each 'while' line as well as before and after the close statements. post the updated code along with the exact output. in doing this we should be able to see exactly where it appears to be stopped listening.

chrism01 09-22-2008 06:55 PM

Show the client code also

All times are GMT -5. The time now is 01:48 PM.