Skip to content

Commit ca828a1

Browse files
authored
fix: Added SO_REUSEADDR to outbound socket to avoid running out of output ports. (#27)
1 parent b70faf0 commit ca828a1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

doc/BUILD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Tested compilers are GCC and Clang.
3434
```bash
3535
$ cmake -S . -B build \
3636
-DCMAKE_BUILD_TYPE=Release # .. or -DCMAKE_BUILD_TYPE=Debug for debugging.
37-
$ (cd build && make)
37+
$ cmake --build build
3838
```
3939

4040
### Windows

questdb-rs/src/ingress/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,14 @@ impl SenderBuilder {
16021602
Domain::IPV4, Type::STREAM, Some(Protocol::TCP))
16031603
.map_err(|io_err| map_io_to_socket_err(
16041604
"Could not open TCP socket: ", io_err))?;
1605+
1606+
// See: https://idea.popcount.org/2014-04-03-bind-before-connect/
1607+
// We set `SO_REUSEADDR` on the outbound socket to avoid issues where a client may exhaust
1608+
// their interface's ports. See: https://github.com/questdb/py-questdb-client/issues/21
1609+
sock.set_reuse_address(true)
1610+
.map_err(|io_err| map_io_to_socket_err(
1611+
"Could not set SO_REUSEADDR: ", io_err))?;
1612+
16051613
sock.set_linger(Some(Duration::from_secs(120)))
16061614
.map_err(|io_err| map_io_to_socket_err(
16071615
"Could not set socket linger: ", io_err))?;

0 commit comments

Comments
 (0)