コード例 #1
0
ファイル: test-tcp.py プロジェクト: rocky/python2-trepan
 def test_client_server(self):
     client = None
     server = None
     try:
         try:
             server = Mserver.TCPServer(opts={'open': True})
         except:
             print("Skipping because of server open failure")
             return
         print("Server port is %s" % server.PORT)
         try:
             client = Mclient.TCPClient(opts={'open': True,
                                             'PORT': server.PORT})
         except IOError:
             print("Skipping because of client open failure")
             return
         for line in ['one', 'two', 'three']:
             server.writeline(line)
             self.assertEqual(line, client.read_msg().rstrip('\n'))
             pass
         for line in ['four', 'five', 'six']:
             client.writeline(line)
             self.assertEqual(line, server.read_msg().rstrip('\n'))
             pass
     finally:
         if client:
             client.close()
         if server:
             server.close()
     return
コード例 #2
0
ファイル: server.py プロジェクト: yssource/python3-trepan
    def __init__(self, inout=None, out=None, connection_opts={}):
        atexit.register(self.finalize)

        opts = DEFAULT_INIT_CONNECTION_OPTS.copy()
        opts.update(connection_opts)
        self.inout = None  # initialize in case assignment below fails
        if inout:
            self.inout = inout
        else:
            self.server_type = opts['IO']
            if 'FIFO' == self.server_type:
                self.inout = Mfifoserver.FIFOServer()
            else:
                self.inout = Mtcpserver.TCPServer(opts=opts)
                pass
            pass
        # For Compatability
        self.output = self.inout
        self.input  = self.inout
        self.interactive = True  # Or at least so we think initially
        self.histfile = None
        return
コード例 #3
0
 def test_client_server(self):
     try:
         server = Mserver.TCPServer(opts={'open': True})
     except:
         print("Skipping because of server open failure")
         return
     try:
         client = Mclient.TCPClient(opts={'open': True})
         for line in ['one', 'two', 'three']:
             server.writeline(line)
             self.assertEqual(line, client.read_msg().rstrip('\n'))
             pass
         for line in ['four', 'five', 'six']:
             client.writeline(line)
             self.assertEqual(line, server.read_msg().rstrip('\n'))
             pass
     except:
         print("Skipping because of client open failure")
         pass
     client.close()
     server.close()
     return
コード例 #4
0
ファイル: server.py プロジェクト: zed/python3-trepan
 def __init__(self, inout=None, out=None, connection_opts=None):
     get_option = lambda key: \
         Mmisc.option_set(connection_opts, key,
                          self.DEFAULT_INIT_CONNECTION_OPTS)
     atexit.register(self.finalize)
     self.inout = None  # initialize in case assignment below fails
     if inout:
         self.inout = inout
     else:
         self.server_type = get_option('IO')
         if 'FIFO' == self.server_type:
             self.inout = Mfifoserver.FIFOServer()
         else:
             self.inout = Mtcpserver.TCPServer(opts=connection_opts)
             pass
         pass
     # For Compatability
     self.output = inout
     self.input = inout
     self.interactive = True  # Or at least so we think initially
     self.histfile = None
     return