Added EventDriverSockets.setKeepAlive.

This commit is contained in:
Sönke Ludwig 2017-01-15 17:21:18 +01:00
parent 2341762992
commit d8f10972eb
4 changed files with 17 additions and 0 deletions

View file

@ -84,6 +84,7 @@ interface EventDriverSockets {
void waitForConnections(StreamListenSocketFD sock, AcceptCallback on_accept);
ConnectionState getConnectionState(StreamSocketFD sock);
void setTCPNoDelay(StreamSocketFD socket, bool enable);
void setKeepAlive(StreamSocketFD socket, bool enable);
void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish);
void cancelRead(StreamSocketFD socket);
void write(StreamSocketFD socket, const(ubyte)[] buffer, IOMode mode, IOCallback on_write_finish);

View file

@ -104,6 +104,11 @@ final class LibasyncEventDriverSockets : EventDriverSockets {
assert(false, "TODO!");
}
override void setKeepAlive(StreamSocketFD socket, bool enable)
{
assert(false, "TODO!");
}
override void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish)
{
assert(false, "TODO!");

View file

@ -350,6 +350,12 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
() @trusted { setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, cast(char*)&opt, opt.sizeof); } ();
}
final override void setKeepAlive(StreamSocketFD socket, bool enable)
{
ubyte opt = enable;
() @trusted { setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, cast(char*)&opt, opt.sizeof); } ();
}
final override void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish)
{
if (buffer.length == 0) {

View file

@ -111,6 +111,11 @@ final class WinAPIEventDriverSockets : EventDriverSockets {
assert(false, "TODO!");
}
override void setKeepAlive(StreamSocketFD socket, bool enable)
{
assert(false, "TODO!");
}
override void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish)
{
assert(false, "TODO!");