Ejemplo n.º 1
0
    def __init__(self, server, request, address):
        """
        Construct the request handler.
        
        @param server: AsyncServer
            The server that created the request.
        @param request: socket
            The connection request socket.
        @param address: tuple(string, integer)
            The client address.
        """
        assert isinstance(server, AsyncServer), "Invalid server %s" % server
        assert isinstance(address, tuple), "Invalid address %s" % address

        dispatcher.__init__(self, request, map=server.map)
        self.server = server
        self.client_address = address
        self.connection = request

        self.request_version = "HTTP/1.1"
        self.requestline = 0

        self._stage = 1
        self.rfile = BytesIO()
        self._readCarry = None
        self._reader = None

        self.wfile = BytesIO()
        self._writeq = deque()

        self._next(1)
Ejemplo n.º 2
0
    def __init__(self, sock, ping, kick):
        self.sock = sock
        self.ping = ping
        self.kick = kick

        self.version = 0
        dispatcher.__init__(self, sock)
Ejemplo n.º 3
0
    def __init__(self, serverAddress, pathProcessing, requestHandlerFactory):
        """
        Construct the server.
        
        @param serverAddress: tuple(string, integer)
            The server address host and port.
        @param pathProcessing: list[tuple(regex, Processing)] 
            A list that contains tuples having on the first position a regex for matching a path, and the second value 
            the processing for handling the path.
        @param requestHandlerFactory: callable(AsyncServer, socket, tuple(string, integer))
            The factory that provides request handlers, takes as arguments the server, request socket
            and client address.
        """
        assert isinstance(serverAddress, tuple), "Invalid server address %s" % serverAddress
        assert isinstance(pathProcessing, list), "Invalid path processing %s" % pathProcessing
        assert callable(requestHandlerFactory), "Invalid request handler factory %s" % requestHandlerFactory

        self.map = {}
        dispatcher.__init__(self, map=self.map)
        self.serverAddress = serverAddress
        self.pathProcessing = pathProcessing
        self.requestHandlerFactory = requestHandlerFactory

        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind(serverAddress)
        self.listen(1024)  # lower this to 5 if your OS complains
Ejemplo n.º 4
0
 def __init__(self, server, address, connection, fromAddress):
     '''
     '''
     dispatcher.__init__ (self, connection)
     self.server = server
     self.address = address
     self.sender = ProxySender(self, address)
Ejemplo n.º 5
0
 def __init__(self,addr,name='nameless',do_log=False):
     self._no_log = not do_log
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(addr)
     self.listen(5)
     self.admin_backlog = []
     self.admin = None
     self.name = name
     self.chans = dict()
     self.users = dict()
     self.pingtimeout = 60 * 5
     self.ping_retry = 2
     self.threads = []
     self.handlers = []
     self.on =True
     for t in [self.pingloop,self.pongloop,self.adminloop]:
         t = self._fork(t)
         self.threads.append(t)
     self.service = dict()
     for t in self.threads:
         t.start()
     for k in services.services.keys():
         self.service[k] = services.services[k](self)
         self.add_user(self.service[k])
Ejemplo n.º 6
0
 def __init__(self, receiver, address):
     '''
     '''
     dispatcher.__init__(self)
     self.receiver = receiver
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.connect(address)
Ejemplo n.º 7
0
 def __init__(self, port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(int(config.get("server", "max_users")))
     self.enterg = EnterGame(self)
 def __init__(self, port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(5)
     self.sessions = []
Ejemplo n.º 9
0
	def __init__(self, ip,port):
		dispatcher.__init__(self)
		self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
		self.bind((ip,port))
		self.listen(5)
		# store all sessions
		self.sessions = []
Ejemplo n.º 10
0
 def __init__(self, request, address, server):
     '''
     Construct the request handler.
     
     @param request: socket
         The connection request socket.
     @param address: tuple(string, integer)
         The client address.
     @param server: AsyncServer
         The server that created the request.
     '''
     assert isinstance(server, AsyncServer), 'Invalid server %s' % server
     assert isinstance(address, tuple), 'Invalid address %s' % address
     dispatcher.__init__(self, request, map=server.map)
     
     self.client_address = address
     self.request = self.connection = request
     self.server = server
     
     self.server_version = server.serverVersion
     
     self._readCarry = None
     self.rfile = BytesIO()
     self._reader = None
     self._chain = None
     
     self.wfile = BytesIO()
     self._writeq = deque()
     
     self._readHeader()
Ejemplo n.º 11
0
	def __init__(self, sock=None, codec=DefaultCodec):
		""" Base transport initializations """
		dispatcher.__init__(self, sock)
		self.codec = codec
		self.inmessages = list()   # list for messaging coming in from media
		self.outmessages = list()  # list of messages to go out to media
		self.sched = None
Ejemplo n.º 12
0
	def __init__(self, port, name):
		dispatcher.__init__(self)
		self.set_reuse_addr()
		self.bind(('',port))
		self.listen(5)
		self.name = name
		self.users = {}
		self.main_room = ChatRoom(self)
Ejemplo n.º 13
0
 def __init__(self, port, name, numberOfConnections):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(("",port))
     self.listen(numberOfConnections)
     self.name = name
     self.sessions = []
Ejemplo n.º 14
0
 def __init__(self, port, name):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.users = {}
     self.main_room = ChatRoom(self)
Ejemplo n.º 15
0
 def __init__(self, port, name):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()   #在服务器没有关闭的情况下重用端口
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.sessions = []
    def __init(self, port):  # 必须要这么写初始化的
        dispatcher.__init__(self)  # 初始化发报机

        self.create_socket(socket.AF_INET, socket.STREAM)
        self.set_reuse_addr()
        self.bind(("", port))
        self.listen(5)
        self.sessions = []  # 初始化会话内容
Ejemplo n.º 17
0
 def __init__(self,parent):
     dispatcher.__init__(self)
     self.parent = parent
     self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(self.parent.bind_addr)
     self.listen(5)
     self.dbg = lambda m : self.parent.dbg('linkserv Listener>> %s'%m)
Ejemplo n.º 18
0
 def __init__(self, url):
   self.url = url
   self.parsed_url = urlparse(url)
   dispatcher.__init__(self)
   self.write_buffer = 'GET %s HTTP/1.0\r\n\r\n' % self.url
   self.read_buffer = StringIO()
   self.create_socket(AF_INET, SOCK_STREAM)
   address = (self.parsed_url.netloc, 80)
   self.connect(address)
Ejemplo n.º 19
0
 def __init__(self, messaging, port=5151, interface=""):
     self.port = port
     self.channels = set()
     self.synclock = RLock()
     self.dispatching = Event()
     self.interface = interface
     self.messaging = messaging
     self.monitor = self.messaging.monitor
     dispatcher.__init__(self, map=self.monitor)
 def __init__(self, port, name):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.users = {}
     self.rooms = {}
Ejemplo n.º 21
0
 def __init__(self, port, name):
     dispatcher.__init__(self)        #标准设置任务
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()       #在服务器没有正确关闭的情况下重用同一个地址
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.users = {}
     self.main_room = ChatRoom(self)
Ejemplo n.º 22
0
 def __init__(self, port, name):
     # Standard setup tasks
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(("", port))
     self.listen(5)
     self.name = name
     self.sessions = []
Ejemplo n.º 23
0
 def __init__(self,port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(("",port))
     self.listen(5)
     self.users={}
     self.main_room=ChatRoom(self,"main")
     self.rooms={"main":self.main_room}
Ejemplo n.º 24
0
    def __init__(self,host,port,logger):

        dispatcher.__init__(self)
        self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind((host,port))
        self.listen(10)
        self.logger = logger
        self.sessions = {}
Ejemplo n.º 25
0
 def __init__(self, port, name):
     #standard setup tasks
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()       #在服务器没有正确关闭的情况下重用同一个地址
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.sessions = []
Ejemplo n.º 26
0
 def __init__(self, port, manager):
     dispatcher.__init__(self)
     self.manager = manager
     self.handler = None
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     # Allows a socket still in the TIME_WAIT state to be used.
     self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.bind(("0.0.0.0", port))
     self.listen(1)
Ejemplo n.º 27
0
 def __init__(self, port, name):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(5)
     self.sessions = []
     
     self.service = build('translate', 'v2', developerKey=G_API_KEY)
Ejemplo n.º 28
0
    def __init__(self, host=None, port=8989):
        dispatcher.__init__(self)

        self.create_socket(AF_INET, SOCK_STREAM)
        dict.__init__(self, {self.fileno(): self})
        print "server started!"
        self.set_reuse_addr()
        self.bind((host, port))
        self.listen(0xA)
        self.dataSource = 3.14134124124124
Ejemplo n.º 29
0
	def __init__(self, ip,port,backlog,name):
		dispatcher.__init__(self)
		self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
		self.bind((ip,port))
		self.listen(backlog)
		self.name = name
		# store all users and sessions in a dict like: name session
		self.users = {}
		# stotr main room
		self.main_room = ChatRoom(self)
Ejemplo n.º 30
0
 def __init__(self, port, name):
     # Standard setup tasks
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(5)
     self.name = name
     self.users = {}
     self.main_room = ChatRoom(self)
Ejemplo n.º 31
0
 def __init__(self, port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.bind(("", port))
     self.listen(1024)
Ejemplo n.º 32
0
 def __init__(self, host, port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.set_reuse_addr()
     self.bind((host, port))
Ejemplo n.º 33
0
 def __init__(self, monitor):
     self.number = self.counter.increment()
     self.debug = False
     self.monitor = monitor
     AsyncChannel.__init__(self)
     AsyncDispatcher.__init__(self, map=monitor)
Ejemplo n.º 34
0
	def __init__(self, sock):
		dispatcher.__init__(self, sock)
		self.packeter = Packeter()
		self.out_buffer = ''
		self.OnRecvMessage = None
Ejemplo n.º 35
0
	def __init__(self):
		dispatcher.__init__(self)
		self.create_socket( socket.AF_INET, socket.SOCK_STREAM )
		self.bind( ( '', 50000 ) )
		self.listen(1)
Ejemplo n.º 36
0
 def __init__(self, url, trayicon):
     dispatcher.__init__(self)
     self._trayicon = trayicon
     self._url = url
     self._stopevent = Event()
     self._reconnect()
Ejemplo n.º 37
0
 def __init__(s, p):
     dispatcher.__init__(s)
     s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     s.set_reuse_addr()
     s.bind(('', p))
     s.listen(20)
Ejemplo n.º 38
0
 def __init__(self, port):  # 重写构造方法
     dispatcher.__init__(self)  # 重载超类的构造方法
     self.create_socket()  # 创建套接字对象
     self.set_reuse_addr()  # 设置地址可重用
     self.bind(('', port))  # 绑定本机地址与端口
     self.listen(5)  # 设置监听连接数
Ejemplo n.º 39
0
 def __init__(self, host, port, family=AF_INET, type=SOCK_STREAM, map=None):
     dispatcher.__init__(self, map=map)
     self.create_socket(family, type)
     self.connect((host, port))
     self.host = host
     self.port = port
 def __init__(self,port):
     dispatcher.__init__()
     self.createsocket()
     adress=(' ',port)
     self.bind(adress)
     self.listen(4)
Ejemplo n.º 41
0
 def __init__(self, port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', port))
     self.listen(5)
Ejemplo n.º 42
0
 def __init__(self):
     dispatcher.__init__(self)
     self.create_socket(AF_INET, SOCK_STREAM)
     self.connect(("localhost", PORT))
Ejemplo n.º 43
0
 def __init__(self,host,port):
     dispatcher.__init__(self)
     self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
     self.set_reuse_addr()
     self.connect((host,port))
Ejemplo n.º 44
0
 def __init__(self, address):
     dispatcher.__init__(self)
     self.message = None
     self.iterator = None
     self._source = None
     self.address = address
Ejemplo n.º 45
0
		def __init__(self, sock,queue):
				self.sock=sock
				self.queue=queue
				self.sendqueue = Queue()
				dispatcher.__init__(self, sock=sock)
				return