| ... | ... | @@ -217,7 +217,10 @@ pub const Address = extern union { |
| 217 | 217 | /// If more than this many connections pool in the kernel, clients will start |
| 218 | 218 | /// seeing "Connection refused". |
| 219 | 219 | kernel_backlog: u31 = 128, |
| 220 | /// Sets SO_REUSEADDR and SO_REUSEPORT on POSIX. |
| 221 | /// Sets SO_REUSEADDR on Windows, which is roughly equivalent. |
| 220 | 222 | reuse_address: bool = false, |
| 223 | /// Deprecated. Does nothing. |
| 221 | 224 | reuse_port: bool = false, |
| 222 | 225 | force_nonblocking: bool = false, |
| 223 | 226 | }; |
| ... | ... | @@ -242,15 +245,15 @@ pub const Address = extern union { |
| 242 | 245 | posix.SO.REUSEADDR, |
| 243 | 246 | &mem.toBytes(@as(c_int, 1)), |
| 244 | 247 | ); |
| 245 | | } |
| 246 | | |
| 247 | | if (options.reuse_port) { |
| 248 | | try posix.setsockopt( |
| 249 | | sockfd, |
| 250 | | posix.SOL.SOCKET, |
| 251 | | posix.SO.REUSEPORT, |
| 252 | | &mem.toBytes(@as(c_int, 1)), |
| 253 | | ); |
| 248 | switch (builtin.os.tag) { |
| 249 | .windows => {}, |
| 250 | else => try posix.setsockopt( |
| 251 | sockfd, |
| 252 | posix.SOL.SOCKET, |
| 253 | posix.SO.REUSEPORT, |
| 254 | &mem.toBytes(@as(c_int, 1)), |
| 255 | ), |
| 256 | } |
| 254 | 257 | } |
| 255 | 258 | |
| 256 | 259 | var socklen = address.getOsSockLen(); |