Restructuring

develop
Sven Slootweg 13 years ago
parent e8afe3e404
commit 9d8879fc37

@ -91,8 +91,8 @@ while select_inputs:
readable, writable, error = select.select(select_inputs, select_outputs, select_inputs) readable, writable, error = select.select(select_inputs, select_outputs, select_inputs)
for sock in readable: for sock in readable:
if sock is bindsocket:
try: try:
if sock is bindsocket:
newsocket, fromaddr = bindsocket.accept() newsocket, fromaddr = bindsocket.accept()
connstream = ssl.wrap_socket(newsocket, connstream = ssl.wrap_socket(newsocket,
server_side=True, server_side=True,
@ -105,9 +105,6 @@ while select_inputs:
select_inputs.append(connstream) select_inputs.append(connstream)
client_map[connstream.fileno()] = new_client client_map[connstream.fileno()] = new_client
client_list.append(new_client) client_list.append(new_client)
except ssl.SSLError:
# todo: handle exception, SSL initialization failed?
pass
else: else:
data = sock.recv(1024) data = sock.recv(1024)
@ -117,6 +114,13 @@ while select_inputs:
else: else:
select_inputs = remove_from_list(select_inputs, sock) select_inputs = remove_from_list(select_inputs, sock)
print "NOTICE: Client disconnected" print "NOTICE: Client disconnected"
except ssl.SSLError, err:
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
select.select([sock], [], [])
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
select.select([], [sock], [])
else:
raise
print "Server socket closed, exiting..." print "Server socket closed, exiting..."
Loading…
Cancel
Save