in reply to Crypt::CBC and IO:Socket

One problem I see with your code is that you are sending binary data but you try to read lines (i.e. strings ending in \n).

You might simply use encrypt_hex() and decrypt_hex() to avoid binary strings. Don't forget to add \n on the sending side and remove it again (with chomp) on the receiving side to have correct line endings.

Or you could keep the binary strings and read fixed length strings with read() or sysread()