def gethostbyname(space, host): """gethostbyname(host) -> address Return the IP address (a string of the form '255.255.255.255') for a host. """ try: addr = rsocket.gethostbyname(host) ip = addr.get_host() except SocketError, e: raise converted_error(space, e)
def gethostbyname(space, w_host): """gethostbyname(host) -> address Return the IP address (a string of the form '255.255.255.255') for a host. """ host = encode_idna(space, w_host) try: addr = rsocket.gethostbyname(host) ip = addr.get_host() except SocketError as e: raise converted_error(space, e) return space.newtext(ip)
def run(directives): hostip = rsocket.gethostbyname('localhost') if use_pypy: host = rsocket.INETAddress(hostip.get_host(), 2222) socket = rsocket.RSocket(rsocket.AF_INET, rsocket.SOCK_STREAM) else: host = (hostip, 2222) socket = rsocket.socket(rsocket.AF_INET, rsocket.SOCK_STREAM) socket.bind(host) socket.listen(1) bufsize = 1048576 while True: if use_pypy: (client_sock_fd, client_addr) = socket.accept() client_sock = rsocket.fromfd(client_sock_fd, rsocket.AF_INET, rsocket.SOCK_STREAM) else: (client_sock, client_addr) = socket.accept() client_sock.send("Server ready!\n") print 'Client contacted' while True: msg = client_sock.recv(bufsize) if use_jit: jitdriver.jit_merge_point( \ # INTs ## REFs msg = msg, client_sock = client_sock # FLOATs ) if not msg: client_sock.close() break msg = msg.rstrip("\n") print "\nRECEIVED:\n%s" % msg if msg == "exit": client_sock.close() break try: ret_msg = directives.parse_and_run_command(msg) except RException as e: ret_msg = "ERROR: " + e.message client_sock.send(ret_msg) print "\nSENT:\n%s" % ret_msg return 1 # could be unindented, if not for rpython
def run(directives): hostip = rsocket.gethostbyname('localhost') if use_pypy: host = rsocket.INETAddress(hostip.get_host(), 2222) socket = rsocket.RSocket(rsocket.AF_INET, rsocket.SOCK_STREAM) else: host = (hostip, 2222) socket = rsocket.socket(rsocket.AF_INET, rsocket.SOCK_STREAM) socket.bind(host) socket.listen(1) bufsize = 1048576 while True: if use_pypy: (client_sock_fd, client_addr) = socket.accept() client_sock = rsocket.fromfd(client_sock_fd, rsocket.AF_INET, rsocket.SOCK_STREAM) else: (client_sock, client_addr) = socket.accept() client_sock.send("Server ready!\n") print 'Client contacted' while True: msg = client_sock.recv(bufsize) if use_jit: jitdriver.jit_merge_point( \ # INTs ## REFs msg = msg, client_sock = client_sock # FLOATs ) if not msg: client_sock.close() break; msg = msg.rstrip("\n") print "\nRECEIVED:\n%s" % msg if msg == "exit": client_sock.close() break; try: ret_msg = directives.parse_and_run_command(msg) except RException as e: ret_msg = "ERROR: " + e.message client_sock.send(ret_msg) print "\nSENT:\n%s" % ret_msg return 1 # could be unindented, if not for rpython
def gethostbynamel(space, name): """ Get a list of IPv4 addresses corresponding to a given Internet host name""" h = rsocket.gethostbyname(name) return space.new_array_from_list([space.newstr(h.get_host())])
def gethostbyname(space, name): """ Get the IPv4 address corresponding to a given Internet host name""" h = rsocket.gethostbyname(name) return space.newstr(h.get_host())