示例#1
0
class Server():
  def __init__(self):
    self.socket = ServerSocket(port=9999)
    self.socket.bind()

  def encode(self, message):
    message = dumps(message, 2)   
    return message

  def decode(self, message):
    try:
      message = loads(message)
    except Exception, e:
      message = None
      print "[X] Error decoding the message from the client %s." % (e)
    return message
示例#2
0
 def __init__(self):
   self.socket = ServerSocket(port=9999)
   self.socket.bind()