[Issue 4234] Cannot create a std.socket.Socket from an fd

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 6 07:20:29 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4234


Daniel Gibson <metalcaedes at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |metalcaedes at gmail.com


--- Comment #1 from Daniel Gibson <metalcaedes at gmail.com> 2010-10-06 07:20:04 PDT ---
I had exactly the same problem, see
http://www.digitalmars.com/d/archives/digitalmars/D/std.socket_is_horrible._115977.html

The easiest way to fix this (as proposed by Christopher E. Miller, the original
author of std.socket), is to just add a constructor that takes a socket_t and a
AddressFamily:

this(socket_t sock, AddressFamily af)
{
    assert(sock != socket_t.init);
    this.sock = sock;
    this._family = af;
}

A related issue however is it's impossible to derive from std.socket.Socket and
overwrite methods that take an std.socket.Address - because the most important
methods of Address (name() and nameLen()) are private and thus can't be
accessed outside of std.Socket. 
This was discussed in aforementioned NG thread as well and the solution is:
 * make these methods (Address.name() and Address.nameLen()) public
 * Socket.newFamilyObject() is private, but should be protected so you can
derive std.Socket to get a Socket that supports new Address types (e.g. local
Addresses)

(That issue is related because it makes it *really* hard to just derive from
std.socket.Socket and overwrite everything and add a constructor that takes a
socket_t. But there are of course other scenarios for deriving from Socket that
are still valid when this bug is fixed.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list