Add EventDriverSockets.getRemoteAddress.
This commit is contained in:
parent
a25b49228f
commit
2e5b13ee98
|
@ -159,6 +159,9 @@ interface EventDriverSockets {
|
|||
/// Retrieves the bind address of a socket.
|
||||
bool getLocalAddress(StreamSocketFD sock, scope RefAddress dst);
|
||||
|
||||
/// Retrieves the address of the connected peer.
|
||||
bool getRemoteAddress(StreamSocketFD sock, scope RefAddress dst);
|
||||
|
||||
/// Sets the `TCP_NODELAY` option on a socket
|
||||
void setTCPNoDelay(StreamSocketFD socket, bool enable);
|
||||
|
||||
|
|
|
@ -213,7 +213,16 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
|||
return m_loop.m_fds[sock].streamSocket.state;
|
||||
}
|
||||
|
||||
bool getLocalAddress(StreamSocketFD sock, scope RefAddress dst)
|
||||
final override bool getLocalAddress(StreamSocketFD sock, scope RefAddress dst)
|
||||
{
|
||||
socklen_t addr_len = dst.nameLen;
|
||||
if (() @trusted { return getpeername(cast(sock_t)sock, dst.name, &addr_len); } () != 0)
|
||||
return false;
|
||||
dst.cap(addr_len);
|
||||
return true;
|
||||
}
|
||||
|
||||
final override bool getRemoteAddress(StreamSocketFD sock, scope RefAddress dst)
|
||||
{
|
||||
socklen_t addr_len = dst.nameLen;
|
||||
if (() @trusted { return getsockname(cast(sock_t)sock, dst.name, &addr_len); } () != 0)
|
||||
|
@ -222,7 +231,6 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
final override void setTCPNoDelay(StreamSocketFD socket, bool enable)
|
||||
{
|
||||
int opt = enable;
|
||||
|
|
|
@ -40,6 +40,11 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
|
|||
assert(false, "TODO!");
|
||||
}
|
||||
|
||||
override bool getRemoteAddress(StreamSocketFD sock, scope RefAddress dst)
|
||||
{
|
||||
assert(false, "TODO!");
|
||||
}
|
||||
|
||||
override void setTCPNoDelay(StreamSocketFD socket, bool enable)
|
||||
{
|
||||
assert(false, "TODO!");
|
||||
|
|
Loading…
Reference in a new issue