<s> """<STR_LIT>""" <EOL> import socket , select <EOL> class GDBSocket ( object ) : <EOL> def __init__ ( self , port , packet_size ) : <EOL> self . packet_size = packet_size <EOL> self . s = None <EOL> self . conn = None <EOL> self . port = port <EOL> self . host = '<STR_LIT>' <EOL> def init ( self ) : <EOL> if self . s is None : <EOL> self . s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> self . s . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , <NUM_LIT:1> ) <EOL> self . s . bind ( ( self . host , self . port ) ) <EOL> self . s . listen ( <NUM_LIT:5> ) <EOL> def connect ( self ) : <EOL> self . conn = None <EOL> self . init ( ) <EOL> rr , _ , _ = select . select ( [ self . s ] , [ ] , [ ] , <NUM_LIT:0.5> ) <EOL> if rr : <EOL> self . conn , _ = self . s . accept ( ) <EOL> return self . conn <EOL> def read ( self ) : <EOL> return self . conn . recv ( self . packet_size ) <EOL> def write ( self , data ) : <EOL> return self . conn . send ( data ) <EOL> def close ( self ) : <EOL> if self . conn is not None : <EOL> self . conn . close ( ) <EOL> self . conn = None <EOL> return_value = None <EOL> if self . s is not None : <EOL> return_value = self . s . close ( ) <EOL> self . s = None <EOL> return return_value <EOL> def setBlocking ( self , blocking ) : <EOL> self . conn . setblocking ( blocking ) <EOL> def setTimeout ( self , timeout ) : <EOL> self . conn . settimeout ( timeout ) </s>
