Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 10, 2024
1 parent 6ce61ce commit e7ade5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 6 additions & 5 deletions vlib/net/tcp.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) ! {
Expand All @@ -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() ! {
Expand Down
9 changes: 5 additions & 4 deletions vlib/net/unix/stream.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) ! {
Expand Down

0 comments on commit e7ade5f

Please sign in to comment.