ConnectEntryPoint.py
929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Associate a physical transport layer with a protocol.
Author: Georg Hopp <ghopp@spamtitan.com>
"""
from EndPoint import CommunicationEndPoint
from Transport import Transport
class ConnectEntryPoint(CommunicationEndPoint):
_EVENTS = {'acc_ready': 0x01}
def __init__(self, transport, protocol):
super(ConnectEntryPoint, self).__init__(transport, protocol)
self._accepted = []
self._transport.bind()
def accept(self):
con = self._transport.accept()
if not con:
return False
while con:
self._accepted.append(con)
try:
con = self._transport.accept()
except Transport.Error as error:
con = None
return True
def pop(self):
try:
return self._accepted.pop()
except IndexError:
return None
# vim: set ft=python et ts=8 sw=4 sts=4: