mirror of
https://github.com/dlang/phobos.git
synced 2025-05-13 15:52:41 +03:00
std.socket: Allow specifying Socket.select timeout as Duration
This commit is contained in:
parent
b7fea71755
commit
1732544f50
1 changed files with 15 additions and 4 deletions
19
std/socket.d
19
std/socket.d
|
@ -2520,10 +2520,11 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Wait for a socket to change status. A wait timeout $(D TimeVal) or
|
||||
* $(D long) microseconds may be specified; if a timeout is not specified
|
||||
* or the $(D TimeVal) is $(D null), the maximum timeout is used. The
|
||||
* $(D TimeVal) timeout has an unspecified value when $(D select) returns.
|
||||
* Wait for a socket to change status. A wait timeout $(D TimeVal),
|
||||
* $(D Duration) or $(D long) microseconds may be specified; if a timeout
|
||||
* is not specified or the $(D TimeVal) is $(D null), the maximum timeout
|
||||
* is used. The $(D TimeVal) timeout has an unspecified value when
|
||||
* $(D select) returns.
|
||||
* Returns: The number of sockets with status changes, $(D 0) on timeout,
|
||||
* or $(D -1) on interruption. If the return value is greater than $(D 0),
|
||||
* the $(D SocketSets) are updated to only contain the sockets having status
|
||||
|
@ -2636,6 +2637,16 @@ public:
|
|||
}
|
||||
|
||||
|
||||
/// ditto
|
||||
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Duration duration)
|
||||
{
|
||||
TimeVal tv;
|
||||
tv.seconds = to!(tv.tv_sec_t )(duration.total!"seconds"());
|
||||
tv.microseconds = to!(tv.tv_usec_t)(duration.fracSec.usecs);
|
||||
return select(checkRead, checkWrite, checkError, &tv);
|
||||
}
|
||||
|
||||
|
||||
/// ditto
|
||||
//maximum timeout
|
||||
static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue