Actions
Bug #17986
closedRactor is stdlib Socket unfriendly
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin19]
Description
Description
In the process of playing with Ractors was found, that there is no way to use stdlib Sockets.
My intent was to implement bidirectional connection with Socket using Ractors.
This small console snippet is self explanatory:
[1] pry(main)> s=Ractor.make_shareable(TCPSocket.open('localhost', 9100))
=> #<TCPSocket:fd 14, AF_INET6, ::1, 52292>
[2] pry(main)> s.print 'foo'
FrozenError: can't modify frozen TCPSocket: #<TCPSocket:fd 14, AF_INET6, ::1, 52292>
from (pry):5:in `write'
[3] pry(main)> s=Ractor.make_shareable(TCPSocket.open('localhost', 9100), copy: true)
=> #<TCPSocket:fd 16, AF_INET6, ::1, 52295>
[4] pry(main)> s.print 'foo'
FrozenError: can't modify frozen TCPSocket: #<TCPSocket:fd 16, AF_INET6, ::1, 52295>
The only option is to move
socket in Ractor, but in this case there is no way to share
the socket between 2 Ractors, so I can not put a listener loop on the socket.
Actions
Like0
Like0Like0Like0Like0