According to perldoc, recv "returns the sender address if the SOCKET protocol supports this, otherwise returns an empty string. If there is an error, the value undefined is returned."
If you get undef, it means that recv encounters an error.
The error in your code is in the following line:
$retValue = $sock->recv($my_message, 64);
The function prototype for recv is:
recv SOCKET,SCALAR,LENGTH,FLAGS
According to perldoc, recv "Attempting to get the LENGTH characters of data into the SCALAR variable from the specified SOCKET file descriptor. SCALAR will be grown or compressed to the length actually read."
Try:
$retvalue = recv($sock, $my_message, 64)
This is where I got all the information: http://perldoc.perl.org/functions/recv.html
source share