wrapSocket for socket_t? As wrapFile for FILE*

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 13 23:33:11 PST 2016


On 02/13/2016 10:38 PM, Beginner-8 wrote:
> On Sunday, 14 February 2016 at 06:10:04 UTC, Beginner-8 wrote:
>> On Sunday, 14 February 2016 at 06:01:11 UTC, tcak wrote:
>>
>>> Unless you explicitly call "close" method of Socket object, its
>>> descriptor will
>>> stay allocated for your process/program.
>>
>> Hmm, I am seen what Socket dtor contains close() too:
>>
>> https://github.com/D-Programming-Language/phobos/blob/master/std/socket.d#L2659
>>
>
> I would say that the socket should not be closed by my code.
>
> For files this way is wrapFile: "The resulting File never takes the
> initiative in closing the file."
> http://dlang.org/library/std/stdio/file.wrap_file.html
>
> It seems that something like this is necessary also for Socket.
>

Maybe another option is to duplicate the socket handle before giving it 
to Socket but I am failing to find a definitive answer or an example.

Ali



More information about the Digitalmars-d-learn mailing list