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

Function gethostbyaddr

crates/stdlib/src/socket.rs:2920–2933  ·  view source on GitHub ↗
(
        addr: PyUtf8StrRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

2918
2919 #[pyfunction]
2920 fn gethostbyaddr(
2921 addr: PyUtf8StrRef,
2922 vm: &VirtualMachine,
2923 ) -> Result<(String, PyListRef, PyListRef), IoOrPyException> {
2924 let addr = get_addr(vm, addr, c::AF_UNSPEC)?;
2925 let (hostname, _) = dns_lookup::getnameinfo(&addr, 0)
2926 .map_err(|e| convert_socket_error(vm, e, SocketError::HError))?;
2927 Ok((
2928 hostname,
2929 vm.ctx.new_list(vec![]),
2930 vm.ctx
2931 .new_list(vec![vm.ctx.new_str(addr.ip().to_string()).into()]),
2932 ))
2933 }
2934
2935 #[pyfunction]
2936 fn gethostbyname(name: PyUtf8StrRef, vm: &VirtualMachine) -> Result<String, IoOrPyException> {

Callers 1

getfqdnFunction · 0.85

Calls 4

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

Tested by

no test coverage detected