Why does my perl server stop working when i press 'enter'?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-05-10T19:56:43Z
Indexed on
2010/05/11
0:24 UTC
Read the original article
Hit count: 300
I have created a server in perl that sends messages or commands to the client. I can send commands just fine, but when i am being prompted for the command on my server i have created, if i press 'enter', the server messes up. Why is this happening?
Here is part of my code:
print "\nConnection recieved from IP address $peer_address on port $peer_port "; $closed_message = "\n\tTerminated client session...";
while (1)
{
print "\nCommand: ";
$send_data = <STDIN>;
chop($send_data);
if ($send_data eq 'e' or $send_data eq 'E' or $send_data eq ' E' or $send_data eq ' E ' or $send_data eq 'E ' or $send_data eq ' e' or $send_data eq ' e ' or $send_data eq 'e')
{
$client_socket->send ($send_data);
close $client_socket;
print "$closed_message\n";
&options;
}
else
{
$client_socket->send($send_data);
}
$client_socket->recv($recieved_data,8000);
print "\nRecieved: $recieved_data";
}
}
© Stack Overflow or respective owner