File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2092,7 +2092,7 @@ static if (is(sockaddr_un))
20922092 {
20932093 auto address = new UnixAddress(name);
20942094
2095- auto listener = new Socket (AddressFamily.UNIX , SocketType.STREAM );
2095+ auto listener = new Socket (AddressFamily.UNIX , SocketType.STREAM , true );
20962096 scope (exit) listener.close();
20972097 listener.bind(address);
20982098 scope (exit) () @trusted { if (name[0 ]) remove(name.tempCString()); } ();
@@ -2661,6 +2661,7 @@ class Socket
26612661private :
26622662 socket_t sock;
26632663 AddressFamily _family;
2664+ const bool closeOnDestruction = true ;
26642665
26652666 version (Windows )
26662667 bool _blocking = true ; // / Property to get or set whether the socket is blocking or nonblocking.
@@ -2772,10 +2773,20 @@ public:
27722773 this ._family = af;
27732774 }
27742775
2776+ // / Use an existing socket handle.
2777+ // /
2778+ // /Params:
2779+ // / closeOnDestruction = If failse doesn't close underlying system socket in the destructor.
2780+ this (socket_t sock, AddressFamily af, bool closeOnDestruction) pure nothrow @nogc
2781+ {
2782+ this .closeOnDestruction = closeOnDestruction;
2783+ this (sock, af);
2784+ }
27752785
27762786 ~this () nothrow @nogc
27772787 {
2778- close();
2788+ if (closeOnDestruction)
2789+ close();
27792790 }
27802791
27812792
You can’t perform that action at this time.
0 commit comments