Merge pull request #291 from BBasile/fix-unixdomain-win

fix, win version broken, unix domain socket code defined in a runtime branch
This commit is contained in:
Brian Schott 2016-02-03 12:51:56 -08:00
commit 9e109d5051
1 changed files with 6 additions and 2 deletions

View File

@ -209,16 +209,20 @@ bool serverIsRunning(bool useTCP, string socketFile, ushort port)
socket.shutdown(SocketShutdown.BOTH); socket.shutdown(SocketShutdown.BOTH);
socket.close(); socket.close();
} }
version(Windows) useTCP = true;
if (useTCP) if (useTCP)
{ {
socket = new TcpSocket(AddressFamily.INET); socket = new TcpSocket(AddressFamily.INET);
socket.connect(new InternetAddress("localhost", port)); socket.connect(new InternetAddress("localhost", port));
} }
else else
{
version(Windows) {} else
{ {
socket = new Socket(AddressFamily.UNIX, SocketType.STREAM); socket = new Socket(AddressFamily.UNIX, SocketType.STREAM);
socket.connect(new UnixAddress(socketFile)); socket.connect(new UnixAddress(socketFile));
} }
}
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"seconds"(5)); socket.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"seconds"(5));
socket.blocking = true; socket.blocking = true;
if (sendRequest(socket, request)) if (sendRequest(socket, request))