1
0
Fork 0

Added command line argument for socket communication

pull/31/head
Stephan Unverwerth 2016-09-22 23:15:53 +02:00
parent ca0fcced20
commit 1a006deee5
1 changed files with 16 additions and 1 deletions

View File

@ -12,6 +12,21 @@ foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../autoload.php', __DI
} }
} }
$server = new LanguageServer(new ProtocolStreamReader(STDIN), new ProtocolStreamWriter(STDOUT)); if (count($argv) >= 3 && $argv[1] == '--tcp') {
$address = $argv[2];
$socket = stream_socket_client('tcp://' . $address, $errno, $errstr);
if ($socket === false) {
fwrite(STDERR, "Could not connect to language client. Error $errno\n");
fwrite(STDERR, "$errstr\n");
exit(1);
}
$inputStream = $outputStream = $socket;
}
else {
$inputStream = STDIN;
$outputStream = STDOUT;
}
$server = new LanguageServer(new ProtocolStreamReader($inputStream), new ProtocolStreamWriter($outputStream));
Loop\run(); Loop\run();