From 340611c298424732255961a6bd2691251801e52e Mon Sep 17 00:00:00 2001 From: Wertzui123 <46199283+Wertzui123@users.noreply.github.com> Date: Sun, 23 Oct 2022 21:21:46 +0200 Subject: [PATCH] net: add a `net.tcp_socket_from_handle_raw` function (#16167) --- vlib/net/tcp.v | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vlib/net/tcp.v b/vlib/net/tcp.v index 7d9cdda329..3899269e07 100644 --- a/vlib/net/tcp.v +++ b/vlib/net/tcp.v @@ -398,6 +398,17 @@ fn tcp_socket_from_handle(sockfd int) !TcpSocket { return s } +// tcp_socket_from_handle_raw is similar to tcp_socket_from_handle, but it does not modify any socket options +pub fn tcp_socket_from_handle_raw(sockfd int) TcpSocket { + mut s := TcpSocket{ + handle: sockfd + } + $if trace_tcp ? { + eprintln(' tcp_socket_from_handle_raw | s.handle: ${s.handle:6}') + } + return s +} + pub fn (mut s TcpSocket) set_option_bool(opt SocketOption, value bool) ! { // TODO reenable when this `in` operation works again // if opt !in opts_can_set {