1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/net/net.v
unknown-v 9d4b4df54f net : fix error msg
from 
os.hostname() cannot get the host name
to
net.hostname() cannot get the host name
2019-07-17 18:42:10 +02:00

14 lines
362 B
V

module net
// hostname returns the host name reported by the kernel.
pub fn hostname() ?string {
mut name := [256]byte
// https://www.ietf.org/rfc/rfc1035.txt
// The host name is returned as a null-terminated string.
res := C.gethostname(&name, 256)
if res != 0 {
return error('net.hostname() cannot get the host name')
}
return tos_clone(name)
}