mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
web socket: fix wss
This commit is contained in:
parent
ed874ffc5b
commit
b4ae332e0c
@ -228,16 +228,37 @@ pub struct C.fd_set {
|
|||||||
// Select waits for an io operation (specified by parameter `test`) to be available
|
// Select waits for an io operation (specified by parameter `test`) to be available
|
||||||
fn @select(handle int, test Select, timeout time.Duration) ?bool {
|
fn @select(handle int, test Select, timeout time.Duration) ?bool {
|
||||||
set := C.fd_set{}
|
set := C.fd_set{}
|
||||||
|
|
||||||
C.FD_ZERO(&set)
|
C.FD_ZERO(&set)
|
||||||
C.FD_SET(handle, &set)
|
C.FD_SET(handle, &set)
|
||||||
timeval_timeout := C.timeval{
|
|
||||||
tv_sec: u64(0)
|
seconds := timeout.milliseconds() / 1000
|
||||||
tv_usec: u64(timeout.microseconds())
|
microseconds := timeout - (seconds * time.second)
|
||||||
|
|
||||||
|
mut tt := C.timeval{
|
||||||
|
tv_sec: u64(seconds)
|
||||||
|
tv_usec: u64(microseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mut timeval_timeout := &tt
|
||||||
|
|
||||||
|
// infinite timeout is signaled by passing null as the timeout to
|
||||||
|
// select
|
||||||
|
if timeout == net.infinite_timeout {
|
||||||
|
timeval_timeout = &C.timeval(0)
|
||||||
|
}
|
||||||
|
|
||||||
match test {
|
match test {
|
||||||
.read { net.socket_error(C.@select(handle, &set, C.NULL, C.NULL, &timeval_timeout))? }
|
.read {
|
||||||
.write { net.socket_error(C.@select(handle, C.NULL, &set, C.NULL, &timeval_timeout))? }
|
net.socket_error(C.@select(handle+1, &set, C.NULL, C.NULL, timeval_timeout))?
|
||||||
.except { net.socket_error(C.@select(handle, C.NULL, C.NULL, &set, &timeval_timeout))? }
|
|
||||||
}
|
}
|
||||||
|
.write {
|
||||||
|
net.socket_error(C.@select(handle+1, C.NULL, &set, C.NULL, timeval_timeout))?
|
||||||
|
}
|
||||||
|
.except {
|
||||||
|
net.socket_error(C.@select(handle+1, C.NULL, C.NULL, &set, timeval_timeout))?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return C.FD_ISSET(handle, &set)
|
return C.FD_ISSET(handle, &set)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user