mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net: support blocking sockets in TcpSocket.connect (#14849)
This commit is contained in:
@@ -379,6 +379,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
fn (mut s TcpSocket) connect(a Addr) ? {
|
fn (mut s TcpSocket) connect(a Addr) ? {
|
||||||
|
$if !net_blocking_sockets ? {
|
||||||
res := C.connect(s.handle, voidptr(&a), a.len())
|
res := C.connect(s.handle, voidptr(&a), a.len())
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
return
|
return
|
||||||
@@ -410,4 +411,7 @@ fn (mut s TcpSocket) connect(a Addr) ? {
|
|||||||
|
|
||||||
// otherwise we timed out
|
// otherwise we timed out
|
||||||
return err_connect_timed_out
|
return err_connect_timed_out
|
||||||
|
} $else {
|
||||||
|
socket_error(C.connect(s.handle, voidptr(&a), a.len()))?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user