def listen_socket(addr, port, cacert, srvcrt, srvkey, nlisten=1):
ls = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ls.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
ls.bind((addr, port))
ls.listen(nlisten)
if cacert is not None and srvcrt is not None and srvkey is not None:
ls = sslize(ls, cacert, srvcrt, srvkey, False)
if not isinstance(ls, SSL.Connection):
return "ERROR could not initialize SSL connection: %s\n" % str(ls)
ls.setblocking(False)
return ls
###
# accept from a listening socket and hand back a SocketNB
###
评论列表
文章目录