2020-08-21 00:01:37 +03:00
|
|
|
module net
|
|
|
|
|
2021-04-22 07:07:56 +03:00
|
|
|
pub enum SocketOption {
|
2023-05-12 09:31:27 +03:00
|
|
|
// TODO: SO_ACCEPT_CONN is not here because windows doesn't support it
|
2020-08-21 00:01:37 +03:00
|
|
|
// and there is no easy way to define it
|
|
|
|
broadcast = C.SO_BROADCAST
|
|
|
|
debug = C.SO_DEBUG
|
|
|
|
dont_route = C.SO_DONTROUTE
|
|
|
|
error = C.SO_ERROR
|
|
|
|
keep_alive = C.SO_KEEPALIVE
|
|
|
|
linger = C.SO_LINGER
|
|
|
|
oob_inline = C.SO_OOBINLINE
|
|
|
|
reuse_addr = C.SO_REUSEADDR
|
2023-05-12 09:31:27 +03:00
|
|
|
receive_buf_size = C.SO_RCVBUF
|
|
|
|
receive_low_size = C.SO_RCVLOWAT
|
|
|
|
receive_timeout = C.SO_RCVTIMEO
|
2020-08-21 00:01:37 +03:00
|
|
|
send_buf_size = C.SO_SNDBUF
|
|
|
|
send_low_size = C.SO_SNDLOWAT
|
|
|
|
send_timeout = C.SO_SNDTIMEO
|
|
|
|
socket_type = C.SO_TYPE
|
2021-06-13 23:53:38 +03:00
|
|
|
ipv6_only = C.IPV6_V6ONLY
|
2020-08-21 00:01:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2021-06-13 23:53:38 +03:00
|
|
|
opts_bool = [SocketOption.broadcast, .debug, .dont_route, .error, .keep_alive, .oob_inline]
|
|
|
|
opts_int = [
|
2023-05-12 09:31:27 +03:00
|
|
|
.receive_buf_size,
|
|
|
|
.receive_low_size,
|
|
|
|
.receive_timeout,
|
2020-08-21 00:01:37 +03:00
|
|
|
.send_buf_size,
|
|
|
|
.send_low_size,
|
|
|
|
.send_timeout,
|
|
|
|
]
|
|
|
|
|
|
|
|
opts_can_set = [
|
|
|
|
SocketOption.broadcast,
|
2021-04-22 07:07:56 +03:00
|
|
|
.debug,
|
|
|
|
.dont_route,
|
|
|
|
.keep_alive,
|
|
|
|
.linger,
|
|
|
|
.oob_inline,
|
2023-05-12 09:31:27 +03:00
|
|
|
.receive_buf_size,
|
|
|
|
.receive_low_size,
|
|
|
|
.receive_timeout,
|
2020-08-21 00:01:37 +03:00
|
|
|
.send_buf_size,
|
|
|
|
.send_low_size,
|
|
|
|
.send_timeout,
|
2021-06-13 23:53:38 +03:00
|
|
|
.ipv6_only,
|
2020-08-21 00:01:37 +03:00
|
|
|
]
|
2021-01-23 12:25:40 +03:00
|
|
|
)
|