fix, unix domain socket code defined in a runtime branch

This commit is contained in:
Basile Burg 2016-02-03 17:01:27 +01:00
parent 9d64081858
commit 3a206f66e3
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))