From 87394165dea1ca1aa3251bfb297542377df96569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88nke=20Ludwig?= Date: Wed, 25 Jan 2017 12:57:02 +0100 Subject: [PATCH] Only bind outgoing stream sockets explicitly if requested. --- source/eventcore/drivers/posix/sockets.d | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/source/eventcore/drivers/posix/sockets.d b/source/eventcore/drivers/posix/sockets.d index 03124bd..b5fc204 100644 --- a/source/eventcore/drivers/posix/sockets.d +++ b/source/eventcore/drivers/posix/sockets.d @@ -48,16 +48,8 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets void invalidateSocket() @nogc @trusted nothrow { closeSocket(sockfd); sock = StreamSocketFD.invalid; } int bret; - () @trusted { // scope + bind() - if (bind_address !is null) { - bret = bind(cast(sock_t)sock, bind_address.name, bind_address.nameLen); - } else { - scope bind_addr = new UnknownAddress; - bind_addr.name.sa_family = cast(ubyte)address.addressFamily; - bind_addr.name.sa_data[] = 0; - bret = bind(cast(sock_t)sock, bind_addr.name, bind_addr.nameLen); - } - } (); + if (bind_address !is null) + () @trusted { bret = bind(cast(sock_t)sock, bind_address.name, bind_address.nameLen); } (); if (bret != 0) { invalidateSocket();