Esempio n. 1
0
def open_network_connections(port):
    s = socket.socket()
    s.connect(('localhost', port))
    in_stream = ph_fdopen(os.dup(s.fileno()), 'r', BUF_SIZE)
    out_stream = ph_fdopen(os.dup(s.fileno()), 'w', BUF_SIZE)
    return NetworkConnections(BinaryDownStreamFilter(in_stream),
                              BinaryUpStreamFilter(out_stream), s, port)
Esempio n. 2
0
def open_network_connections(port):
    s = socket.socket()
    s.connect(('localhost', port))
    in_stream = ph_fdopen(os.dup(s.fileno()), 'r', BUF_SIZE)
    out_stream = ph_fdopen(os.dup(s.fileno()), 'w', BUF_SIZE)
    return NetworkConnections(BinaryDownStreamFilter(in_stream),
                              BinaryUpStreamFilter(out_stream), s, port)
Esempio n. 3
0
 def handle(self):
     self.server.logger.debug('handler started')
     # We have to wait for the cmd flux to start, otherwise it appears that
     # socket data flux gets confused on what is waiting what.
     cmd_flux_has_started = threading.Event()
     fd = self.request.fileno()
     cmd_thread = CommandThread(cmd_flux_has_started,
                                self.server.down_bytes,
                                ph_fdopen(os.dup(fd), 'w',
                                          BUF_SIZE), self.server.logger)
     res_thread = ResultThread(self.server.simulator,
                               ph_fdopen(os.dup(fd), 'r', BUF_SIZE),
                               self.server.out_writer, self.server.logger)
     cmd_thread.start()
     cmd_flux_has_started.wait()
     res_thread.start()
     self.server.logger.debug('Waiting in cmd_thread.join()')
     cmd_thread.join()
     self.server.logger.debug('Waiting in res_thread.join()')
     res_thread.join()
     self.server.logger.debug('handler is done')
Esempio n. 4
0
 def handle(self):
     self.server.logger.debug('handler started')
     # We have to wait for the cmd flux to start, otherwise it appears that
     # socket data flux gets confused on what is waiting what.
     cmd_flux_has_started = threading.Event()
     fd = self.request.fileno()
     cmd_thread = CommandThread(
         cmd_flux_has_started, self.server.down_bytes,
         ph_fdopen(os.dup(fd), 'w', BUF_SIZE), self.server.logger
     )
     res_thread = ResultThread(self.server.simulator,
                               ph_fdopen(os.dup(fd), 'r', BUF_SIZE),
                               self.server.out_writer,
                               self.server.logger)
     cmd_thread.start()
     cmd_flux_has_started.wait()
     res_thread.start()
     self.server.logger.debug('Waiting in cmd_thread.join()')
     cmd_thread.join()
     self.server.logger.debug('Waiting in res_thread.join()')
     res_thread.join()
     self.server.logger.debug('handler is done')