ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:114882] [Ruby master Misc#19899] Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection
@ 2023-09-22 15:35 jbeschi (jacopo beschi) via ruby-core
  2023-09-28 15:34 ` [ruby-core:114909] [Ruby master Misc#19899] Ruby3.3.0-preview2: " alanwu (Alan Wu) via ruby-core
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jbeschi (jacopo beschi) via ruby-core @ 2023-09-22 15:35 UTC (permalink / raw
  To: ruby-core; +Cc: jbeschi (jacopo beschi)

Issue #19899 has been reported by jbeschi (jacopo beschi).



----------------------------------------

Misc #19899: Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection

https://bugs.ruby-lang.org/issues/19899



* Author: jbeschi (jacopo beschi)

* Status: Open

* Priority: Normal

----------------------------------------

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](https://www.ruby-lang.org/en/news/2023/09/14/ruby-3-3-0-preview2-released/). 



Example:





``` ruby

# 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!







-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:114909] [Ruby master Misc#19899] Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection
  2023-09-22 15:35 [ruby-core:114882] [Ruby master Misc#19899] Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection jbeschi (jacopo beschi) via ruby-core
@ 2023-09-28 15:34 ` alanwu (Alan Wu) via ruby-core
  2023-09-28 15:35 ` [ruby-core:114910] " byroot (Jean Boussier) via ruby-core
  2023-09-28 19:36 ` [ruby-core:114912] " alanwu (Alan Wu) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: alanwu (Alan Wu) via ruby-core @ 2023-09-28 15:34 UTC (permalink / raw
  To: ruby-core; +Cc: alanwu (Alan Wu)

Issue #19899 has been updated by alanwu (Alan Wu).





Looks to be an intentional change from [Bug #19012].

CC @byroot 



----------------------------------------

Misc #19899: Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection

https://bugs.ruby-lang.org/issues/19899#change-104778



* Author: jbeschi (jacopo beschi)

* Status: Open

* Priority: Normal

----------------------------------------

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](https://www.ruby-lang.org/en/news/2023/09/14/ruby-3-3-0-preview2-released/). 



Example:





``` ruby

# 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!







-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:114910] [Ruby master Misc#19899] Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection
  2023-09-22 15:35 [ruby-core:114882] [Ruby master Misc#19899] Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection jbeschi (jacopo beschi) via ruby-core
  2023-09-28 15:34 ` [ruby-core:114909] [Ruby master Misc#19899] Ruby3.3.0-preview2: " alanwu (Alan Wu) via ruby-core
@ 2023-09-28 15:35 ` byroot (Jean Boussier) via ruby-core
  2023-09-28 19:36 ` [ruby-core:114912] " alanwu (Alan Wu) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2023-09-28 15:35 UTC (permalink / raw
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #19899 has been updated by byroot (Jean Boussier).





It is intentional yes. I'll add it to NEWS.md.



----------------------------------------

Misc #19899: Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection

https://bugs.ruby-lang.org/issues/19899#change-104779



* Author: jbeschi (jacopo beschi)

* Status: Open

* Priority: Normal

----------------------------------------

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](https://www.ruby-lang.org/en/news/2023/09/14/ruby-3-3-0-preview2-released/). 



Example:





``` ruby

# 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!







-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:114912] [Ruby master Misc#19899] Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection
  2023-09-22 15:35 [ruby-core:114882] [Ruby master Misc#19899] Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection jbeschi (jacopo beschi) via ruby-core
  2023-09-28 15:34 ` [ruby-core:114909] [Ruby master Misc#19899] Ruby3.3.0-preview2: " alanwu (Alan Wu) via ruby-core
  2023-09-28 15:35 ` [ruby-core:114910] " byroot (Jean Boussier) via ruby-core
@ 2023-09-28 19:36 ` alanwu (Alan Wu) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: alanwu (Alan Wu) via ruby-core @ 2023-09-28 19:36 UTC (permalink / raw
  To: ruby-core; +Cc: alanwu (Alan Wu)

Issue #19899 has been updated by alanwu (Alan Wu).



Status changed from Open to Closed



NEWS entry added in commit:2e4e4c82c28. Thanks for the report!



----------------------------------------

Misc #19899: Ruby3.3.0-preview2: Behaviour changes of Socket.recv when the sever closes the connection

https://bugs.ruby-lang.org/issues/19899#change-104781



* Author: jbeschi (jacopo beschi)

* Status: Closed

* Priority: Normal

----------------------------------------

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](https://www.ruby-lang.org/en/news/2023/09/14/ruby-3-3-0-preview2-released/). 



Example:





``` ruby

# 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!







-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-28 19:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-22 15:35 [ruby-core:114882] [Ruby master Misc#19899] Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection jbeschi (jacopo beschi) via ruby-core
2023-09-28 15:34 ` [ruby-core:114909] [Ruby master Misc#19899] Ruby3.3.0-preview2: " alanwu (Alan Wu) via ruby-core
2023-09-28 15:35 ` [ruby-core:114910] " byroot (Jean Boussier) via ruby-core
2023-09-28 19:36 ` [ruby-core:114912] " alanwu (Alan Wu) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).