1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: ipv6 support, merge unix+ip;[pack:x] attribute (#9904)

This commit is contained in:
Emily Hudson
2021-06-13 21:53:38 +01:00
committed by GitHub
parent fa9fa77a5f
commit 535dcac8fa
52 changed files with 1277 additions and 524 deletions

View File

@@ -2,6 +2,20 @@ module net
import time
// no_deadline should be given to functions when no deadline is wanted (i.e. all functions
// return instantly)
const no_deadline = time.Time{
unix: 0
}
// no_timeout should be given to functions when no timeout is wanted (i.e. all functions
// return instantly)
pub const no_timeout = time.Duration(0)
// infinite_timeout should be given to functions when an infinite_timeout is wanted (i.e. functions
// only ever return with data)
pub const infinite_timeout = time.Duration(-1)
// Shutdown shutsdown a socket and closes it
fn shutdown(handle int) ? {
$if windows {
@@ -11,8 +25,6 @@ fn shutdown(handle int) ? {
C.shutdown(handle, C.SHUT_RDWR)
socket_error(C.close(handle)) ?
}
return none
}
// Select waits for an io operation (specified by parameter `test`) to be available
@@ -23,7 +35,7 @@ fn @select(handle int, test Select, timeout time.Duration) ?bool {
C.FD_SET(handle, &set)
seconds := timeout.milliseconds() / 1000
microseconds := timeout - (seconds * time.second)
microseconds := time.Duration(timeout - (seconds * time.second)).microseconds()
mut tt := C.timeval{
tv_sec: u64(seconds)
@@ -63,7 +75,7 @@ fn wait_for_common(handle int, deadline time.Time, timeout time.Duration, test S
}
ready := @select(handle, test, timeout) ?
if ready {
return none
return
}
return err_timed_out
}
@@ -78,7 +90,7 @@ fn wait_for_common(handle int, deadline time.Time, timeout time.Duration, test S
ready := @select(handle, test, d_timeout) ?
if ready {
return none
return
}
return err_timed_out
}
@@ -92,23 +104,3 @@ fn wait_for_write(handle int, deadline time.Time, timeout time.Duration) ? {
fn wait_for_read(handle int, deadline time.Time, timeout time.Duration) ? {
return wait_for_common(handle, deadline, timeout, .read)
}
// no_deadline should be given to functions when no deadline is wanted (i.e. all functions
// return instantly)
const (
no_deadline = time.Time{
unix: 0
}
)
// no_timeout should be given to functions when no timeout is wanted (i.e. all functions
// return instantly)
pub const (
no_timeout = time.Duration(0)
)
// infinite_timeout should be given to functions when an infinite_timeout is wanted (i.e. functions
// only ever return with data)
pub const (
infinite_timeout = time.Duration(-1)
)