Actions
Misc #19899
closedRuby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection
Status:
Closed
Assignee:
-
Description
I noticed that Socket#recv
now returns nil
instead of ""
when the server closes the connection, is it expected? If yes, I suggest mentioning it to the release page.
Example:
# server.rb
require "socket"
port = 3030
server = TCPServer.new("", port)
while(conn = server.accept) #serves forever
conn.print "hello"
conn.close
end
# client.rb
require 'socket'
port = 3030
socket = TCPSocket.new("localhost", port)
2.times do
res = socket.recv(1012)
puts "received:"
p res
end
socket.close
jacopo-37s-mb 3.2.0 ~ ruby client.rb
received:
"hello"
received:
""
jacopo-37s-mb 3.2.0 ~ rbenv local 3.3.0-preview2
jacopo-37s-mb 3.3.0-preview2 ~ ruby client.rb
received:
"hello"
received:
nil
Thanks!
Updated by jbeschi (jacopo beschi) over 1 year ago
- Subject changed from Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection to Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection
Updated by alanwu (Alan Wu) about 1 year ago
Looks to be an intentional change from [Bug #19012].
CC @byroot (Jean Boussier)
Updated by byroot (Jean Boussier) about 1 year ago
It is intentional yes. I'll add it to NEWS.md.
Updated by alanwu (Alan Wu) about 1 year ago
- Status changed from Open to Closed
NEWS entry added in 2e4e4c82c28. Thanks for the report!
Actions
Like0
Like0Like0Like1Like1