Project

General

Profile

Actions

Feature #8042

open

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

Added by drbrain (Eric Hodel) about 11 years ago. Updated over 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:53203]

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.


Files

addrinfo.socket.patch (2.54 KB) addrinfo.socket.patch drbrain (Eric Hodel), 03/08/2013 08:35 AM
addrinfo.socket.2.patch (2.6 KB) addrinfo.socket.2.patch Addrinfo#unbound_socket drbrain (Eric Hodel), 03/12/2013 02:18 AM

Updated by akr (Akira Tanaka) about 11 years ago

2013/3/8 drbrain (Eric Hodel) :

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

Updated by drbrain (Eric Hodel) about 11 years 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?

Updated by akr (Akira Tanaka) about 11 years ago

2013/3/11 drbrain (Eric Hodel) :

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

Updated by drbrain (Eric Hodel) about 11 years 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?

Updated by akr (Akira Tanaka) about 11 years ago

2013/3/12 drbrain (Eric Hodel) :

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

Updated by zzak (zzak _) almost 11 years ago

  • Status changed from Open to Assigned
  • Assignee set to drbrain (Eric Hodel)

Updated by drbrain (Eric Hodel) almost 11 years ago

  • Assignee changed from drbrain (Eric Hodel) to matz (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.

Updated by headius (Charles Nutter) almost 11 years ago

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

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

Updated by akr (Akira Tanaka) almost 11 years ago

2013/6/24 headius (Charles Nutter) :

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

I think it is natural because object oriented.

Tanaka Akira

Updated by headius (Charles Nutter) almost 11 years ago

On Tue, Jun 25, 2013 at 3:56 AM, Tanaka Akira wrote:

2013/6/24 headius (Charles Nutter) :

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

Updated by naruse (Yui NARUSE) over 10 years ago

  • Target version changed from 2.1.0 to 2.6
Actions #12

Updated by naruse (Yui NARUSE) over 6 years ago

  • Target version deleted (2.6)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0