Feature #8042

Add Addrinfo#socket to create a socket that is not connected or bound

Added by Eric Hodel about 1 year ago. Updated 7 months ago.

[ruby-core:53203]
Status:Assigned
Priority:Normal
Assignee:Yukihiro Matsumoto
Category:ext
Target version:next minor

Description

This adds a socket method to Addrinfo to get a socket that has not been bound or connected to any address for connectionless operation.

addrinfo.socket.patch Magnifier (2.54 KB) Eric Hodel, 03/08/2013 08:35 AM

addrinfo.socket.2.patch Magnifier - Addrinfo#unbound_socket (2.6 KB) Eric Hodel, 03/12/2013 02:18 AM

History

#1 Updated by Akira Tanaka about 1 year ago

2013/3/8 drbrain (Eric Hodel) drbrain@segment7.net:

Feature #8042: Add Addrinfo#socket to create a socket that is not connected or bound
https://bugs.ruby-lang.org/issues/8042

This adds a socket method to Addrinfo to get a socket that has not been bound or connected to any address for connectionless operation.

I think the method name, Addrinfo#socket, is too generic.

I feel that Addrinfo#socket method uses socket address in Addrinfo object,
but this proposal doesn't.
--
Tanaka Akira

#2 Updated by Eric Hodel about 1 year ago

How about unbound_socket?

I would like to use a feature like this one in rinda/ring.rb for multicast support since options need to be set before connect/bind (see #8073)

Perhaps #connect_to or #bind could take a block that would yield the socket for setsockopt before bind/connect?

#3 Updated by Akira Tanaka about 1 year ago

2013/3/11 drbrain (Eric Hodel) drbrain@segment7.net:

How about unbound_socket?

I like unbound_socket.

Perhaps #connect_to or #bind could take a block that would yield the socket for setsockopt before bind/connect?

It conflicts with current block usage of Addrinfo#connect_to and Addrinfo#bind.
--
Tanaka Akira

#4 Updated by Eric Hodel about 1 year ago

Here is an updated patch using #unbound_socket, may I commit?

PS: ext/socket has no listed maintainer, should it be you, Akira-san?

#5 Updated by Akira Tanaka about 1 year ago

2013/3/12 drbrain (Eric Hodel) drbrain@segment7.net:

PS: ext/socket has no listed maintainer, should it be you, Akira-san?

When I want to change API, I tried to obtain approval by matz.
--
Tanaka Akira

#6 Updated by Zachary Scott 11 months ago

  • Status changed from Open to Assigned
  • Assignee set to Eric Hodel

#7 Updated by Eric Hodel 11 months ago

  • Assignee changed from Eric Hodel to Yukihiro Matsumoto

matz, I need your approval to add Addrinfo#unbound_socket which creates a connectionless socket that allows you to set further socket options before connect or to use in a connectionless manner.

#8 Updated by Charles Nutter 10 months ago

Objection: why would an "info" object be able to create a socket?

Wouldn't Socket.unbound_socket(addrinfo) make more sense?

#9 Updated by Akira Tanaka 10 months ago

2013/6/24 headius (Charles Nutter) headius@headius.com:

Objection: why would an "info" object be able to create a socket?

I think it is natural because object oriented.
--
Tanaka Akira

#10 Updated by Charles Nutter 10 months ago

On Tue, Jun 25, 2013 at 3:56 AM, Tanaka Akira akr@fsij.org wrote:

2013/6/24 headius (Charles Nutter) headius@headius.com:

Objection: why would an "info" object be able to create a socket?

I think it is natural because object oriented.

If the object's type were "Address" I might agree. But it's
"AddrInfo"...information about an address. I don't see the OOness of
an informational object being able to do this sort of thing.

I'm bikeshedding of course, but passing address info to a Socket
constructor seems far more OO to me than an address info creating a
socket on its own. Socket should be responsible for creating Socket
instances.

  • Charlie

#11 Updated by Yui NARUSE 7 months ago

  • Target version changed from 2.1.0 to next minor

Also available in: Atom PDF