diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-12-09 18:59:38 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2022-12-11 17:17:58 +0100 |
commit | 6d799f0aed18be25a5c908499b6411ab6d06b78c (patch) | |
tree | 3e6a91048c7fe3e78bae9f75b24eb37c5504681b /libphobos/src/std/socket.d | |
parent | cc7f509d3c0b3ab63891cf7ca2def0fdfb3642c4 (diff) | |
download | gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.zip gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.gz gcc-6d799f0aed18be25a5c908499b6411ab6d06b78c.tar.bz2 |
d: Merge upstream dmd, druntime c8ae4adb2e, phobos 792c8b7c1.
D front-end changes:
- Import dmd v2.101.0.
- Deprecate the ability to call `__traits(getAttributes)' on
overload sets.
- Deprecate non-empty `for' statement increment clause with no
effect.
- Array literals assigned to `scope' array variables can now be
allocated on the stack.
D runtime changes:
- Import druntime v2.101.0.
Phobos changes:
- Import phobos v2.101.0.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd c8ae4adb2e.
* typeinfo.cc (check_typeinfo_type): Update for new front-end
interface.
(TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Remove warning
that toHash() must be declared 'nothrow @safe`.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime c8ae4adb2e.
* src/MERGE: Merge upstream phobos 792c8b7c1.
Diffstat (limited to 'libphobos/src/std/socket.d')
-rw-r--r-- | libphobos/src/std/socket.d | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d index fb2c2d4..593052e 100644 --- a/libphobos/src/std/socket.d +++ b/libphobos/src/std/socket.d @@ -2628,7 +2628,7 @@ private: AddressFamily _family; version (Windows) - bool _blocking = false; /// Property to get or set whether the socket is blocking or nonblocking. + bool _blocking = true; /// Property to get or set whether the socket is blocking or nonblocking. // The WinSock timeouts seem to be effectively skewed by a constant // offset of about half a second (value in milliseconds). This has @@ -2641,22 +2641,22 @@ private: { if (runSlowTests) softUnittest({ - import std.datetime.stopwatch; - import std.typecons; + import std.datetime.stopwatch : StopWatch; + import std.typecons : Yes; enum msecs = 1000; auto pair = socketPair(); - auto sock = pair[0]; - sock.setOption(SocketOptionLevel.SOCKET, + auto testSock = pair[0]; + testSock.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"msecs"(msecs)); auto sw = StopWatch(Yes.autoStart); ubyte[1] buf; - sock.receive(buf); + testSock.receive(buf); sw.stop(); Duration readBack = void; - sock.getOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, readBack); + testSock.getOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, readBack); assert(readBack.total!"msecs" == msecs); assert(sw.peek().total!"msecs" > msecs - 100 && sw.peek().total!"msecs" < msecs + 100); @@ -2751,6 +2751,21 @@ public: } /** + * Releases the underlying socket handle from the Socket object. Once it + * is released, you cannot use the Socket object's methods anymore. This + * also means the Socket destructor will no longer close the socket - it + * becomes your responsibility. + * + * To get the handle without releasing it, use the `handle` property. + */ + @property socket_t release() pure nothrow @nogc + { + auto h = sock; + this.sock = socket_t.init; + return h; + } + + /** * Get/set socket's blocking flag. * * When a socket is blocking, calls to receive(), accept(), and send() |