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

net: simplify TcpListener.accept, use C.accept(l.sock.handle, 0, 0), since we do not care about the local address of the accepted connection

This commit is contained in:
Delyan Angelov 2022-04-12 11:47:41 +03:00
parent 716cb17aea
commit 9b43713ec5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -239,16 +239,10 @@ pub fn (mut l TcpListener) accept() ?&TcpConn {
$if trace_tcp ? {
eprintln(' TcpListener.accept | l.sock.handle: ${l.sock.handle:6}')
}
addr := Addr{
addr: AddrData{
Ip6: Ip6{}
}
}
size := sizeof(Addr)
mut new_handle := C.accept(l.sock.handle, voidptr(&addr), &size)
mut new_handle := C.accept(l.sock.handle, 0, 0)
if new_handle <= 0 {
l.wait_for_accept() ?
new_handle = C.accept(l.sock.handle, voidptr(&addr), &size)
new_handle = C.accept(l.sock.handle, 0, 0)
if new_handle == -1 || new_handle == 0 {
return error('accept failed')
}