diff --git a/vlib/net/tcp.c.v b/vlib/net/tcp.c.v index a91a7b1c10324f..37bccc58e46735 100644 --- a/vlib/net/tcp.c.v +++ b/vlib/net/tcp.c.v @@ -570,8 +570,8 @@ pub fn tcp_socket_from_handle_raw(sockfd int) TcpSocket { return s } -fn (mut s TcpSocket) set_option(level int, opt int, value voidptr) ! { - socket_error(C.setsockopt(s.handle, level, opt, value, sizeof(int)))! +fn (mut s TcpSocket) set_option(level int, opt int, value int) ! { + socket_error(C.setsockopt(s.handle, level, opt, &value, sizeof(int)))! } pub fn (mut s TcpSocket) set_option_bool(opt SocketOption, value bool) ! { @@ -582,16 +582,17 @@ pub fn (mut s TcpSocket) set_option_bool(opt SocketOption, value bool) ! { // if opt !in opts_bool { // return err_option_wrong_type // } - s.set_option(C.SOL_SOCKET, int(opt), &int(value))! + x := int(value) + s.set_option(C.SOL_SOCKET, int(opt), x)! } pub fn (mut s TcpSocket) set_option_int(opt SocketOption, value int) ! { - s.set_option(C.SOL_SOCKET, int(opt), &int(value))! + s.set_option(C.SOL_SOCKET, int(opt), value)! } pub fn (mut s TcpSocket) set_dualstack(on bool) ! { x := int(!on) - s.set_option(C.IPPROTO_IPV6, int(SocketOption.ipv6_only), &x)! + s.set_option(C.IPPROTO_IPV6, int(SocketOption.ipv6_only), x)! } fn (mut s TcpSocket) set_default_options() ! { diff --git a/vlib/net/unix/stream.c.v b/vlib/net/unix/stream.c.v index 476ed9ed6f851a..c44536ad59ec67 100644 --- a/vlib/net/unix/stream.c.v +++ b/vlib/net/unix/stream.c.v @@ -412,8 +412,8 @@ fn (mut s StreamSocket) @select(test Select, timeout time.Duration) !bool { } // set_option sets an option on the socket -fn (mut s StreamSocket) set_option(level int, opt int, value voidptr) ! { - net.socket_error(C.setsockopt(s.handle, level, opt, value, sizeof(int)))! +fn (mut s StreamSocket) set_option(level int, opt int, value int) ! { + net.socket_error(C.setsockopt(s.handle, level, opt, &value, sizeof(int)))! } // set_option_bool sets a boolean option on the socket @@ -424,12 +424,13 @@ pub fn (mut s StreamSocket) set_option_bool(opt net.SocketOption, value bool) ! if opt !in net.opts_bool { return net.err_option_wrong_type } - s.set_option(C.SOL_SOCKET, int(opt), &int(value))! + x := int(value) + s.set_option(C.SOL_SOCKET, int(opt), x)! } // set_option_bool sets an int option on the socket pub fn (mut s StreamSocket) set_option_int(opt net.SocketOption, value int) ! { - s.set_option(C.SOL_SOCKET, int(opt), &int(value))! + s.set_option(C.SOL_SOCKET, int(opt), value)! } fn (mut s StreamSocket) connect(socket_path string) ! {