in reply to Re^2: Client-Server Programme hangs...
in thread Client-Server Programme hangs...

One other thing. Make sure you put $socket->autoflush() immediately after you create the socket at the client side, and $session->autoflush() immediately after you accept the connection on the server side. In your current code the proper place to do a $socket->close() would be after the return from host_to_user.

Replies are listed 'Best First'.
Re^4: Client-Server Programme hangs...
by aodukoya (Initiate) on Jan 04, 2005 at 08:07 UTC
    Hello Errto,
    Thanks for your last suggestions I have implemented all that you said but it really did not help, to resolve the issue. It's still hanging...

    sub host_to_user { + my $nread ; my $inp ; $/ = CRLF ; while (<$socket>) { chomp; + my @data = split/-/, $_ ; print $_ , "\n"; print "The first value is $data[1]\n"; if ($data[1] eq 'THISISTHEEND') { $socket->close ; print " I have executed the close\n"; return 0 ; } } # + $socket->close ; #<- position 2 ###print " I have executed the close\n"; # return ; }

    The output is still the same the following is the output of the above code.

    $ ./client Testing> Hello I have received your message[server]-THISISTHEEND The first value is THISISTHEEND I have executed the close Testing> So what ^C$ $

    I even tried to put the $socket->close () in what I mentioned as position 2, but that was worse and the execution never got to the close section so I took it out.
      Then my only suggestion is to put some print statements in your server code, run it in a terminal, and make sure that the loop reading from $session actually exits when it should.