本文整理汇总了Python中asyncore.dispatcher_with_send方法的典型用法代码示例。如果您正苦于以下问题:Python asyncore.dispatcher_with_send方法的具体用法?Python asyncore.dispatcher_with_send怎么用?Python asyncore.dispatcher_with_send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asyncore
的用法示例。
在下文中一共展示了asyncore.dispatcher_with_send方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, markov, sock, remote_server, remote_port):
self.markov = markov
asyncore.dispatcher_with_send.__init__(self, sock)
msock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
msock.connect((remote_server, remote_port))
self.msock = LocalProxy.ToMTunnelServer(markov, self, msock)
示例2: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, conn, certfile):
self.socket = ssl.wrap_socket(conn, server_side=True,
certfile=certfile,
do_handshake_on_connect=False)
asyncore.dispatcher_with_send.__init__(self, self.socket)
self._ssl_accepting = True
self._do_ssl_handshake()
示例3: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, conn, certfile):
asyncore.dispatcher_with_send.__init__(self, conn)
self.socket = ssl.wrap_socket(conn, server_side=True,
certfile=certfile,
do_handshake_on_connect=False)
self._ssl_accepting = True
示例4: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, sock, interface, server):
asyncore.dispatcher_with_send.__init__(self, sock=sock)
self._datastore = ModbusDataStore(interface.di, interface.co, interface.ir, interface.hr)
self._modbus = ModbusProtocol(self.send, self._datastore)
self._server = server
self._set_logging_context(interface)
self.log.info('Client connected from %s:%s', *sock.getpeername())
示例5: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, sock, callback=None, high_speed=True,
parser=None, daisy=False):
asyncore.dispatcher_with_send.__init__(self, sock)
self.callback = callback
self.daisy = daisy
self.high_speed = high_speed
self.last_odd_sample = OpenBCISample()
self.parser = parser if parser is not None else ParseRaw(
gains=[24, 24, 24, 24, 24, 24, 24, 24])
示例6: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, async_socket, handlers, settings):
"""async echo handler based on asyncore.dispatcher_with_send
:param async_socket: the socket object
:param handlers: handlers mapping
:param settings: settings config
"""
self.logger = logging.getLogger()
self.__handlers = handlers
self.__settings = settings
asyncore.dispatcher_with_send.__init__(self, sock=async_socket)
示例7: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, sock, localEndpoint, remoteEndpoint, secret,
dataCbFun, ctlCbFun, ctlCbCtx):
self.__localEndpoint = localEndpoint
self.__remoteEndpoint = remoteEndpoint
self.__secret = secret
self.__dataCbFun = dataCbFun
self.__ctlCbFun = ctlCbFun
self.__ctlCbCtx = ctlCbCtx
self.__pendingReqs = {}
self.__pendingCounter = 0
self.__input = null
self.socket = None # asyncore strangeness
asyncore.dispatcher_with_send.__init__(self, sock)
try:
self.socket.setsockopt(
socket.SOL_SOCKET, socket.SO_SNDBUF, 65535
)
self.socket.setsockopt(
socket.SOL_SOCKET, socket.SO_RCVBUF, 65535
)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
except socket.error:
raise error.SnmpfwdError('%s socket error: %s' % (self, sys.exc_info()[1]))
else:
log.info('%s: serving new connection...' % (self,))
示例8: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, localEndpoint, remoteEndpoint, secret, dataCbFun):
localAf, self.__localEndpoint = localEndpoint[0], localEndpoint[1:]
remoteAf, self.__remoteEndpoint = remoteEndpoint[0], remoteEndpoint[1:]
self.__secret = secret
self.__dataCbFun = dataCbFun
self.__pendingReqs = {}
self.__pendingCounter = 0
self.__input = null
self.__announcementData = null
if localAf != remoteAf:
raise error.SnmpfwdError('%s: mismatching address family')
asyncore.dispatcher_with_send.__init__(self)
try:
self.create_socket(localAf, socket.SOCK_STREAM)
self.socket.setsockopt(
socket.SOL_SOCKET, socket.SO_SNDBUF, 65535
)
self.socket.setsockopt(
socket.SOL_SOCKET, socket.SO_RCVBUF, 65535
)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self.bind(self.__localEndpoint)
self.connect(self.__remoteEndpoint)
except socket.error:
raise error.SnmpfwdError('%s socket error: %s' % (self, sys.exc_info()[1]))
log.info('%s: initiated trunk client connection from %s to %s...' % (self, localEndpoint, remoteEndpoint))
示例9: __init__
# 需要导入模块: import asyncore [as 别名]
# 或者: from asyncore import dispatcher_with_send [as 别名]
def __init__(self, conn, certfile):
self.socket = test_wrap_socket(conn, server_side=True,
certfile=certfile,
do_handshake_on_connect=False)
asyncore.dispatcher_with_send.__init__(self, self.socket)
self._ssl_accepting = True
self._do_ssl_handshake()