Skip to content

Commit

Permalink
Remove support for socket connections. We might add these back, but w…
Browse files Browse the repository at this point in the history
…e're not maintaining them anymore
  • Loading branch information
puremourning committed Oct 9, 2017
1 parent 13b70ff commit f3cd062
Showing 1 changed file with 0 additions and 131 deletions.
131 changes: 0 additions & 131 deletions ycmd/completers/language_server/language_server_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import logging
import threading
import socket
import json
import os
import queue
Expand Down Expand Up @@ -230,136 +229,6 @@ def _Read( self, size=-1 ):
raise RuntimeError( 'Not implemented' )



class TCPSingleStreamServer( LanguageServerConnection, threading.Thread ):
def __init__( self, port ):
super( TCPSingleStreamServer, self ).__init__()

self._port = port
self._socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self._client_socket = None


def run( self ):
self._socket.bind( ( 'localhost', self._port ) )
self._socket.listen( 0 )

self._run_loop()


def _TryServerConnectionBlocking( self ):
( self._client_socket, _ ) = self._socket.accept()
_logger.info( 'language server socket connected' )

return True


def _Write( self, data ):
assert self._connection_event.isSet()
assert self._client_socket

total_sent = 0
while total_sent < len( data ):
sent = self._client_socket.send( data[ total_sent: ] )
if sent == 0:
raise RuntimeError( 'write socket failed' )

total_sent += sent


def _Read( self, size=-1 ):
assert self._connection_event.isSet()
assert self._client_socket

if size < 0:
data = self._client_socket.recv( 2048 )
if data == '':
raise RuntimeError( 'read socket failed' )

return data

chunks = []
bytes_read = 0
while bytes_read < size:
chunk = self._client_socket.recv( min( size - bytes_read , 2048 ) )
if chunk == '':
raise RuntimeError( 'read socket failed' )

chunks.append( chunk )
bytes_read += len( chunk )

return utils.ToBytes( '' ).join( chunks )


class TCPMultiStreamServer( LanguageServerConnection, threading.Thread ):
def __init__( self, input_port, output_port ):
super( TCPMultiStreamServer, self ).__init__()

self._connection_event = threading.Event()

self._input_port = input_port
self._input_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM )

self._output_port = output_port
self._output_socket = socket.socket( socket.AF_INET, socket.SOCK_STREAM )

self._client_read_socket = None
self._client_write_socket = None


def run( self ):
self._input_socket.bind( ( 'localhost', self._input_port ) )
self._input_socket.listen( 0 )

self._output_socket.bind( ( 'localhost', self._output_port ) )
self._output_socket.listen( 0 )

self._run_loop()


def _TryServerConnectionBlocking( self ):
( self._client_read_socket, _ ) = self._input_socket.accept()
_logger.info( 'Language server Input socket connected' )

( self._client_write_socket, _ ) = self._output_socket.accept()
_logger.info( 'Language server Output socket connected' )


def _Write( self, data ):
assert self._client_write_socket

total_sent = 0
while total_sent < len( data ):
sent = self._client_write_socket.send( data[ total_sent: ] )
if sent == 0:
raise RuntimeError( 'write socket failed' )

total_sent += sent


def _Read( self, size=-1 ):
assert self._client_read_socket

if size < 0:
data = self._client_read_socket.recv( 2048 )
if data == '':
raise RuntimeError( 'read socket failed' )

return data

chunks = []
bytes_read = 0
while bytes_read < size:
chunk = self._client_read_socket.recv( min( size - bytes_read , 2048 ) )
if chunk == '':
raise RuntimeError( 'read socket failed' )

chunks.append( chunk )
bytes_read += len( chunk )

return utils.ToBytes( '' ).join( chunks )


class StandardIOLanguageServerConnection( LanguageServerConnection,
threading.Thread ):
def __init__( self, server_stdin, server_stdout ):
Expand Down

0 comments on commit f3cd062

Please sign in to comment.