diff options
| author | Caleb Maclennan <caleb@alerque.com> | 2026-08-31 10:57:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-31 10:57:42 +0300 |
| commit | 535178a3f0e2cff59f4d59ee3a655bee263a5c90 (patch) | |
| tree | 22d97c928a8043fd7e4a89897b163ab3deba9591 /src | |
| parent | 84c2bb905bda5f1fc58195171c75723b5fec6e87 (diff) | |
| parent | a9a1e25fdec1faba0237a554027a0f717f132c51 (diff) | |
| download | luasocket-535178a3f0e2cff59f4d59ee3a655bee263a5c90.tar.gz luasocket-535178a3f0e2cff59f4d59ee3a655bee263a5c90.tar.bz2 luasocket-535178a3f0e2cff59f4d59ee3a655bee263a5c90.zip | |
Merge pull request #449 from Wires77/add_SO_EXCLUSIVEADDRUSE
Add option for SO_EXCLUSIVEADDRUSE in Windows
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.c | 20 | ||||
| -rw-r--r-- | src/options.h | 5 | ||||
| -rw-r--r-- | src/tcp.c | 6 | ||||
| -rw-r--r-- | src/udp.c | 6 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index 9dea6bd..1c3eb1c 100644 --- a/src/options.c +++ b/src/options.c | |||
| @@ -94,6 +94,26 @@ int opt_get_reuseaddr(lua_State *L, p_socket ps) | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /*------------------------------------------------------*/ | 96 | /*------------------------------------------------------*/ |
| 97 | /* enables reuse of local address */ | ||
| 98 | int opt_set_exclusiveaddruse(lua_State* L, p_socket ps) | ||
| 99 | { | ||
| 100 | #ifndef SO_EXCLUSIVEADDRUSE | ||
| 101 | return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system"); | ||
| 102 | #else | ||
| 103 | return opt_setboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE); | ||
| 104 | #endif | ||
| 105 | } | ||
| 106 | |||
| 107 | int opt_get_exclusiveaddruse(lua_State* L, p_socket ps) | ||
| 108 | { | ||
| 109 | #ifndef SO_EXCLUSIVEADDRUSE | ||
| 110 | return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system"); | ||
| 111 | #else | ||
| 112 | return opt_getboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE); | ||
| 113 | #endif | ||
| 114 | } | ||
| 115 | |||
| 116 | /*------------------------------------------------------*/ | ||
| 97 | /* enables reuse of local port */ | 117 | /* enables reuse of local port */ |
| 98 | int opt_set_reuseport(lua_State *L, p_socket ps) | 118 | int opt_set_reuseport(lua_State *L, p_socket ps) |
| 99 | { | 119 | { |
diff --git a/src/options.h b/src/options.h index 26d6f02..6d6d7e0 100644 --- a/src/options.h +++ b/src/options.h | |||
| @@ -28,6 +28,11 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); | |||
| 28 | int opt_set_reuseaddr(lua_State *L, p_socket ps); | 28 | int opt_set_reuseaddr(lua_State *L, p_socket ps); |
| 29 | int opt_get_reuseaddr(lua_State *L, p_socket ps); | 29 | int opt_get_reuseaddr(lua_State *L, p_socket ps); |
| 30 | 30 | ||
| 31 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 32 | int opt_set_exclusiveaddruse(lua_State* L, p_socket ps); | ||
| 33 | int opt_get_exclusiveaddruse(lua_State* L, p_socket ps); | ||
| 34 | #endif | ||
| 35 | |||
| 31 | int opt_set_reuseport(lua_State *L, p_socket ps); | 36 | int opt_set_reuseport(lua_State *L, p_socket ps); |
| 32 | int opt_get_reuseport(lua_State *L, p_socket ps); | 37 | int opt_get_reuseport(lua_State *L, p_socket ps); |
| 33 | 38 | ||
| @@ -74,6 +74,9 @@ static t_opt optget[] = { | |||
| 74 | {"bindtodevice", opt_get_bindtodevice}, | 74 | {"bindtodevice", opt_get_bindtodevice}, |
| 75 | {"keepalive", opt_get_keepalive}, | 75 | {"keepalive", opt_get_keepalive}, |
| 76 | {"reuseaddr", opt_get_reuseaddr}, | 76 | {"reuseaddr", opt_get_reuseaddr}, |
| 77 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 78 | {"exclusiveaddruse", opt_get_exclusiveaddruse}, | ||
| 79 | #endif | ||
| 77 | {"reuseport", opt_get_reuseport}, | 80 | {"reuseport", opt_get_reuseport}, |
| 78 | {"tcp-nodelay", opt_get_tcp_nodelay}, | 81 | {"tcp-nodelay", opt_get_tcp_nodelay}, |
| 79 | #ifdef TCP_KEEPIDLE | 82 | #ifdef TCP_KEEPIDLE |
| @@ -96,6 +99,9 @@ static t_opt optset[] = { | |||
| 96 | {"bindtodevice", opt_set_bindtodevice}, | 99 | {"bindtodevice", opt_set_bindtodevice}, |
| 97 | {"keepalive", opt_set_keepalive}, | 100 | {"keepalive", opt_set_keepalive}, |
| 98 | {"reuseaddr", opt_set_reuseaddr}, | 101 | {"reuseaddr", opt_set_reuseaddr}, |
| 102 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 103 | {"exclusiveaddruse", opt_set_exclusiveaddruse}, | ||
| 104 | #endif | ||
| 99 | {"reuseport", opt_set_reuseport}, | 105 | {"reuseport", opt_set_reuseport}, |
| 100 | {"tcp-nodelay", opt_set_tcp_nodelay}, | 106 | {"tcp-nodelay", opt_set_tcp_nodelay}, |
| 101 | #ifdef TCP_KEEPIDLE | 107 | #ifdef TCP_KEEPIDLE |
| @@ -74,6 +74,9 @@ static t_opt optset[] = { | |||
| 74 | {"dontroute", opt_set_dontroute}, | 74 | {"dontroute", opt_set_dontroute}, |
| 75 | {"broadcast", opt_set_broadcast}, | 75 | {"broadcast", opt_set_broadcast}, |
| 76 | {"reuseaddr", opt_set_reuseaddr}, | 76 | {"reuseaddr", opt_set_reuseaddr}, |
| 77 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 78 | {"exclusiveaddruse", opt_set_exclusiveaddruse}, | ||
| 79 | #endif | ||
| 77 | {"reuseport", opt_set_reuseport}, | 80 | {"reuseport", opt_set_reuseport}, |
| 78 | {"ip-multicast-if", opt_set_ip_multicast_if}, | 81 | {"ip-multicast-if", opt_set_ip_multicast_if}, |
| 79 | {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, | 82 | {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, |
| @@ -96,6 +99,9 @@ static t_opt optget[] = { | |||
| 96 | {"dontroute", opt_get_dontroute}, | 99 | {"dontroute", opt_get_dontroute}, |
| 97 | {"broadcast", opt_get_broadcast}, | 100 | {"broadcast", opt_get_broadcast}, |
| 98 | {"reuseaddr", opt_get_reuseaddr}, | 101 | {"reuseaddr", opt_get_reuseaddr}, |
| 102 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 103 | {"exclusiveaddruse", opt_get_exclusiveaddruse}, | ||
| 104 | #endif | ||
| 99 | {"reuseport", opt_get_reuseport}, | 105 | {"reuseport", opt_get_reuseport}, |
| 100 | {"ip-multicast-if", opt_get_ip_multicast_if}, | 106 | {"ip-multicast-if", opt_get_ip_multicast_if}, |
| 101 | {"ip-multicast-loop", opt_get_ip_multicast_loop}, | 107 | {"ip-multicast-loop", opt_get_ip_multicast_loop}, |
