MCPcopy Index your code
hub / github.com/RustPython/RustPython / gethostbyname_ex

Function gethostbyname_ex

crates/stdlib/src/socket.rs:2945–2958  ·  view source on GitHub ↗
(
        name: PyUtf8StrRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

2943
2944 #[pyfunction]
2945 fn gethostbyname_ex(
2946 name: PyUtf8StrRef,
2947 vm: &VirtualMachine,
2948 ) -> Result<(String, PyListRef, PyListRef), IoOrPyException> {
2949 let addr = get_addr(vm, name, c::AF_INET)?;
2950 let (hostname, _) = dns_lookup::getnameinfo(&addr, 0)
2951 .map_err(|e| convert_socket_error(vm, e, SocketError::HError))?;
2952 Ok((
2953 hostname,
2954 vm.ctx.new_list(vec![]),
2955 vm.ctx
2956 .new_list(vec![vm.ctx.new_str(addr.ip().to_string()).into()]),
2957 ))
2958 }
2959
2960 #[pyfunction]
2961 fn inet_pton(af_inet: i32, ip_string: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<Vec<u8>> {

Callers

nothing calls this directly

Calls 4

get_addrFunction · 0.85
getnameinfoFunction · 0.85
convert_socket_errorFunction · 0.85
new_listMethod · 0.80

Tested by

no test coverage detected