jettero identified the problem correctly. However, setting $/ = CRLF on the client side won't help, as it's the input record separator, yet the \r\n (CRLF) needs to be sent on output, i.e. at the end of the $msg_out string in the statement print $socket $msg_out; .
Anyway, the easiest way to get this demo to work is to remove the $/ = CRLF; in the server code. Alternatively, you could add $msg_out =~ s/\n/\r\n/; right before the print $socket $msg_out; . (On unix, the string returned by STDIN->getline will be terminated by just \n, not \r\n.)
With this modification, you should see (assuming the server is running):
$ ./tcp_echo_cli2.pl localhost 2007 foobar raboof
BTW, a good way to debug things like these yourself is to insert simple print ... statements to find out exactly where things are not working as expected. (In this case, you'd have seen that it doesn't get past the while (<$session>) { line in the server...)
In reply to Re: socket gone crazy
by almut
in thread socket gone crazy
by spx2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |