Skip to Content
Programming Perl, 4th Edition
book

Programming Perl, 4th Edition

by Tom Christiansen, brian d foy, Larry Wall, Jon Orwant
February 2012
Intermediate to advanced
1184 pages
37h 17m
English
O'Reilly Media, Inc.
Content preview from Programming Perl, 4th Edition

recv

recv SOCKET, SCALAR, LEN, FLAGS

This function receives a message on a socket. It attempts to receive LENGTH characters (codepoints) of data into variable SCALAR from the specified SOCKET filehandle. The function returns the address of the sender or undef if there’s an error. SCALAR will grow or shrink to the length actually read. The function takes the same flags as recv(2), and it is actually implemented using the recvfrom(2). See the section Sockets in Chapter 15.

Note the characters: depending on the status of the socket, either undecoded (8-bit) bytes or fully decoded characters are received. By default, all sockets operate on bytes. But, for example, if the socket has been changed using binmode to operate with the :encoding(utf8) I/O layer, the I/O will operate on UTF-8-encoded Unicode characters, not bytes.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Perl, 3rd Edition

Programming Perl, 3rd Edition

Larry Wall, Tom Christiansen, Jon Orwant
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes
Learning Perl, 8th Edition

Learning Perl, 8th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9781449321451Supplemental ContentErrata Page