Update BasicSocket#recv documentation on return value

Ref: https://github.com/ruby/ruby/pull/6407

[Bug #19012]

`0` is now interpreted as closed connection an not an
empty packet, as these are very rare and pretty much
useless.
This commit is contained in:
Jean Boussier 2023-12-18 10:17:15 +01:00 committed by Jean Boussier
parent 40fc9b070c
commit b2fc1b054e

View File

@ -333,9 +333,10 @@ class BasicSocket < IO
# _flags_ is zero or more of the +MSG_+ options. # _flags_ is zero or more of the +MSG_+ options.
# The result, _mesg_, is the data received. # The result, _mesg_, is the data received.
# #
# When recvfrom(2) returns 0, Socket#recv_nonblock returns # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
# an empty string as data. # In most cases it means the connection was closed, but for UDP connections
# The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc. # it may mean an empty packet was received, as the underlying API makes
# it impossible to distinguish these two cases.
# #
# === Parameters # === Parameters
# * +maxlen+ - the number of bytes to receive from the socket # * +maxlen+ - the number of bytes to receive from the socket
@ -480,9 +481,10 @@ class Socket < BasicSocket
# The second element, _sender_addrinfo_, contains protocol-specific address # The second element, _sender_addrinfo_, contains protocol-specific address
# information of the sender. # information of the sender.
# #
# When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
# an empty string as data. # In most cases it means the connection was closed, but for UDP connections
# The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc. # it may mean an empty packet was received, as the underlying API makes
# it impossible to distinguish these two cases.
# #
# === Parameters # === Parameters
# * +maxlen+ - the maximum number of bytes to receive from the socket # * +maxlen+ - the maximum number of bytes to receive from the socket
@ -1229,9 +1231,10 @@ class UDPSocket < IPSocket
# The first element of the results, _mesg_, is the data received. # The first element of the results, _mesg_, is the data received.
# The second element, _sender_inet_addr_, is an array to represent the sender address. # The second element, _sender_inet_addr_, is an array to represent the sender address.
# #
# When recvfrom(2) returns 0, # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
# Socket#recvfrom_nonblock returns an empty string as data. # In most cases it means the connection was closed, but it may also mean
# It means an empty packet. # an empty packet was received, as the underlying API makes
# it impossible to distinguish these two cases.
# #
# === Parameters # === Parameters
# * +maxlen+ - the number of bytes to receive from the socket # * +maxlen+ - the number of bytes to receive from the socket