First, you should read from CLIENT, not from $client_addr:
while ( defined ($response = <CLIENT>) ){
Next, you have to flush (or autoflush) when you write something on either side. Otherwise, due to buffering, the messages will not be available on the other side right away, resulting in a deadlock, because both sides will wait for the other side to say something... One way would be to use IO::Handle:
use IO::Handle; ... print CLIENT "Hello from the server \n\n "; CLIENT->flush(); ...
and similarly on the client side.
Also, as both client and server are in a readline while loop, you'll likely want to have some protocol that defines when to stop reading and terminate the connection.
Finally, when you read lines on the server side, you also have to print a line on the client side:
print SOCKET "Client says hellooooo toooo !!! \n"; # ^^ SOCKET->flush();
Otherwise, the server will hang in $response = <CLIENT>, waiting for the newline...
In reply to Re^3: Simple question regarding Bidirectional socket programming
by almut
in thread Simple question regarding Bidirectional socket programming
by sajanagr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |