コード例 #1
0
    def handleAccept(self, rc, evt):
        if self.disconnecting or self.disconnected:
            return False

        # possible errors:
        # (WSAEMFILE, WSAENOBUFS, WSAENFILE, WSAENOMEM, WSAECONNABORTED)
        if rc:
            log.msg("Could not accept new connection -- %s (%s)" %
                    (errno.errorcode.get(rc, 'unknown error'), rc))
            return False
        else:
            evt.newskt.setsockopt(socket.SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
                                  struct.pack('I', self.socket.fileno()))
            family, lAddr, rAddr = _iocp.get_accept_addrs(
                evt.newskt.fileno(), evt.buff)
            assert family == self.addressFamily

            protocol = self.factory.buildProtocol(
                address._ServerFactoryIPv4Address('TCP', rAddr[0], rAddr[1]))
            if protocol is None:
                evt.newskt.close()
            else:
                s = self.sessionno
                self.sessionno = s + 1
                transport = Server(
                    evt.newskt, protocol,
                    address.IPv4Address('TCP', rAddr[0], rAddr[1], 'INET'),
                    address.IPv4Address('TCP', lAddr[0], lAddr[1], 'INET'), s,
                    self.reactor)
                protocol.makeConnection(transport)
            return True
コード例 #2
0
    def getPeer(self):
        """
		Returns an IPv4Address.

		This indicates the address that I am connected to.
		"""
        return address.IPv4Address('TCP', *(self.realAddress + ('INET', )))
コード例 #3
0
    def getHost(self):
        """Returns an IPv4Address.

		This indicates the server's address.
		"""
        return address.IPv4Address('TCP',
                                   *(self.socket.getsockname() + ('INET', )))
コード例 #4
0
    def getHost(self):
        """Returns an IPv4Address.

		This indicates the address from which I am connecting.
		"""
        return address.IPv4Address('TCP',
                                   *(self.socket.getsockname() + ('INET', )))
コード例 #5
0
ファイル: ssl.py プロジェクト: samis/blockBox
	def getDestination(self):
		return address.IPv4Address('TCP', self.host, self.port, 'SSL')
コード例 #6
0
ファイル: ssl.py プロジェクト: samis/blockBox
	def getPeer(self):
		"""Return address of peer."""
		h, p = self.client
		return address.IPv4Address('TCP', h, p, 'SSL')
コード例 #7
0
ファイル: ssl.py プロジェクト: samis/blockBox
	def getHost(self):
		"""Return server's address."""
		h, p = self.socket.getsockname()
		return address.IPv4Address('TCP', h, p, 'SSL')
コード例 #8
0
ファイル: ssl.py プロジェクト: samis/blockBox
	def getPeer(self):
		"""Returns the address that I am connected."""
		return address.IPv4Address('TCP', self.addr[0], self.addr[1], 'SSL')
コード例 #9
0
ファイル: ssl.py プロジェクト: samis/blockBox
	def getHost(self):
		"""Returns the address from which I am connecting."""
		h, p = self.socket.getsockname()
		return address.IPv4Address('TCP', h, p, 'SSL')
コード例 #10
0
    def getPeer(self):
        """Returns an IPv4Address.

		This indicates the client's address.
		"""
        return address.IPv4Address('TCP', *(self.client + ('INET', )))