Implement support for TCPListenOptions.reusePort.

This commit is contained in:
Sönke Ludwig 2017-01-27 22:51:17 +01:00
parent b391ebabbe
commit 798f0ef446
No known key found for this signature in database
GPG key ID: D95E8DB493EE314C

View file

@ -99,8 +99,10 @@ TCPListener listenTCP(ushort port, TCPConnectionDelegate connection_callback, st
{
auto addr = resolveHost(address);
addr.port = port;
assert(options == TCPListenOptions.defaults, "TODO");
auto sock = eventDriver.sockets.listenStream(addr.toUnknownAddress,
StreamListenOptions sopts = StreamListenOptions.defaults;
if (options & TCPListenOptions.reusePort)
sopts |= StreamListenOptions.reusePort;
auto sock = eventDriver.sockets.listenStream(addr.toUnknownAddress, sopts,
(StreamListenSocketFD ls, StreamSocketFD s, scope RefAddress addr) @safe nothrow {
import vibe.core.core : runTask;
auto conn = TCPConnection(s, addr);