From 9b43713ec5437b0fb8c6568b3fb9e214270fe89f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 12 Apr 2022 11:47:41 +0300 Subject: [PATCH] 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 --- vlib/net/tcp.v | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/vlib/net/tcp.v b/vlib/net/tcp.v index 428629398d..bbe30b353b 100644 --- a/vlib/net/tcp.v +++ b/vlib/net/tcp.v @@ -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') }