On Sunday, 14 February 2016 at 04:13:12 UTC, Beginner-8 wrote:
Hi!
Anyone seen Socket constructor which uses already available
socket of socket_t type?
I am need to use already connected socket imported from C
library without closing them after using.
One of the constructors of class Socket is as follows:
pure nothrow @nogc @safe this(socket_t sock, AddressFamily af);
socket_t is basically a file descriptor which is the type "int".
Your C library provides you "socket_t" value already as far as I
understand.
So, you can pass it to constructor.
Unless you explicitly call "close" method of Socket object, its
descriptor will
stay allocated for your process/program.