python asyncio create_connection()-处理连接被拒绝

时间:2019-03-15 19:40:10

标签: python asynchronous networking

我正在使用要点https://gist.github.com/sandrogauci/9618007 我想处理第46行上被拒绝的conn,该怎么办?我也想终止客户端conn。

class PortForwarder(asyncio.Protocol):
def __init__(self, dsthost, dstport):
    self.dsthost = dsthost 
    self.dstport = dstport

def connection_made(self, transport):
    self.transport = transport
    loop = asyncio.get_event_loop()
    self.fcon = ForwardedConnection(self.transport)
    asyncio.async(loop.create_connection(lambda: self.fcon, self.dsthost, self.dstport))

0 个答案:

没有答案