Perl recv Function


Advertisements


Description

This function receives a message on SOCKET attempting to read LENGTH bytes, placing the data read into variable SCALAR.The FLAGS argument takes the same values as the recvfrom( ) system function, on which the function is based. When communicating with sockets, this provides a more reliable method of reading fixed-length data than the sysread function or the line-based operator <FH>.

Syntax

Following is the simple syntax for this function −

recv SOCKET, SCALAR, LEN, FLAGS

Return Value

This function returns in Scalar Context: undef on error or Number of bytes read.

Example

Following is the example code showing its basic usage −


When above code is executed, it produces the following result −




Advertisements