Fix interaction of --tcp and --port

This commit is contained in:
Hackerpilot 2016-03-03 00:50:48 -08:00
parent 219b0716c0
commit eab78141c4
3 changed files with 23 additions and 2 deletions
src
client
common
server

View File

@ -40,7 +40,7 @@ int main(string[] args)
size_t cursorPos = size_t.max; size_t cursorPos = size_t.max;
string[] importPaths; string[] importPaths;
ushort port = 9166; ushort port;
bool help; bool help;
bool shutdown; bool shutdown;
bool clearCache; bool clearCache;
@ -102,6 +102,14 @@ int main(string[] args)
return 1; 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) if (useTCP)
socketFile = null; socketFile = null;

View File

@ -28,6 +28,8 @@ version (linux) version = haveUnixSockets;
version (BSD) version = haveUnixSockets; version (BSD) version = haveUnixSockets;
version (FreeBSD) version = haveUnixSockets; version (FreeBSD) version = haveUnixSockets;
enum DEFAULT_PORT_NUMBER = 9166;
string generateSocketName() string generateSocketName()
{ {
version (haveUnixSockets) version (haveUnixSockets)

View File

@ -56,7 +56,7 @@ version(OSX) version = useXDG;
int main(string[] args) int main(string[] args)
{ {
ushort port = 9166; ushort port;
bool help; bool help;
bool printVersion; bool printVersion;
bool ignoreConfig; bool ignoreConfig;
@ -107,6 +107,17 @@ int main(string[] args)
return 0; 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) version (Windows) if (socketFile !is null)
{ {
fatal("UNIX domain sockets not supported on Windows"); fatal("UNIX domain sockets not supported on Windows");