def _create_server(host, port):
exc = socket.error("<STR_LIT>")<EOL>for res in socket.getaddrinfo(host, port, <NUM_LIT:0>, socket.SOCK_STREAM):<EOL><INDENT>af, socktype, proto, canonname, sa = res<EOL>sock = None<EOL>try:<EOL><INDENT>sock = socket.socket(af, socktype, proto)<EOL>sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, <NUM_LIT:1>)<EOL>sock.bind(sa)<EOL>sock.listen(<NUM_LIT>)<EOL>return sock<EOL><DEDENT>except socket.error as exc:<EOL><INDENT>if sock is not None:<EOL><INDENT>sock.close()<EOL><DEDENT><DEDENT><DEDENT>raise exc<EOL>
Helper function.  Creates a listening socket on the designated
host and port.  Modeled on the socket.create_connection()
function.