diff --git a/src/client/client.d b/src/client/client.d index 7511d9f..5421dec 100644 --- a/src/client/client.d +++ b/src/client/client.d @@ -40,7 +40,7 @@ int main(string[] args) size_t cursorPos = size_t.max; string[] importPaths; - ushort port = 9166; + ushort port; bool help; bool shutdown; bool clearCache; @@ -102,6 +102,14 @@ int main(string[] args) return 1; } + // If the user specified a port number, assume that they wanted a TCP + // connection. Otherwise set the port number to the default and let the + // useTCP flag deterimen what to do later. + if (port != 0) + useTCP = true; + else + port = DEFAULT_PORT_NUMBER; + if (useTCP) socketFile = null; diff --git a/src/common/socket.d b/src/common/socket.d index eed6b40..9fb2528 100644 --- a/src/common/socket.d +++ b/src/common/socket.d @@ -28,6 +28,8 @@ version (linux) version = haveUnixSockets; version (BSD) version = haveUnixSockets; version (FreeBSD) version = haveUnixSockets; +enum DEFAULT_PORT_NUMBER = 9166; + string generateSocketName() { version (haveUnixSockets) diff --git a/src/server/server.d b/src/server/server.d index fa7a32f..f0eac2c 100644 --- a/src/server/server.d +++ b/src/server/server.d @@ -56,7 +56,7 @@ version(OSX) version = useXDG; int main(string[] args) { - ushort port = 9166; + ushort port; bool help; bool printVersion; bool ignoreConfig; @@ -107,6 +107,17 @@ int main(string[] args) return 0; } + // If the user specified a port number, assume that they wanted a TCP + // connection. Otherwise set the port number to the default and let the + // useTCP flag deterimen what to do later. + if (port != 0) + useTCP = true; + else + port = DEFAULT_PORT_NUMBER; + + if (useTCP) + socketFile = null; + version (Windows) if (socketFile !is null) { fatal("UNIX domain sockets not supported on Windows");