diff options
-rw-r--r-- | include/libbb.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/libbb.h b/include/libbb.h index 7b456a9fa..912505026 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -282,6 +282,13 @@ void xlisten(int s, int backlog); | |||
282 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); | 282 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); |
283 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, | 283 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, |
284 | socklen_t tolen); | 284 | socklen_t tolen); |
285 | /* SO_REUSEADDR allows a server to rebind to an address that is already | ||
286 | * "in use" by old connections to e.g. previous server instance which is | ||
287 | * killed or crashed. Without it bind will fail until all such connections | ||
288 | * time out. Linux does not allow multiple live binds on same ip:port | ||
289 | * regardless of SO_REUSEADDR (unlike some other flavors of Unix). | ||
290 | * Turn it on before you call bind(). */ | ||
291 | //TODO: it seems like in Linux this never fails. Change to void, eliminate error checks | ||
285 | int setsockopt_reuseaddr(int fd); | 292 | int setsockopt_reuseaddr(int fd); |
286 | int setsockopt_broadcast(int fd); | 293 | int setsockopt_broadcast(int fd); |
287 | /* NB: returns port in host byte order */ | 294 | /* NB: returns port in host byte order */ |
@@ -318,6 +325,7 @@ int xsocket_stream(len_and_sockaddr **lsap); | |||
318 | * numeric IP ("N.N.N.N") or numeric IPv6 address, | 325 | * numeric IP ("N.N.N.N") or numeric IPv6 address, |
319 | * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). | 326 | * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). |
320 | * Only if there is no suffix, port argument is used */ | 327 | * Only if there is no suffix, port argument is used */ |
328 | /* NB: these set SO_REUSEADDR before bind */ | ||
321 | int create_and_bind_stream_or_die(const char *bindaddr, int port); | 329 | int create_and_bind_stream_or_die(const char *bindaddr, int port); |
322 | int create_and_bind_dgram_or_die(const char *bindaddr, int port); | 330 | int create_and_bind_dgram_or_die(const char *bindaddr, int port); |
323 | /* Create client TCP socket connected to peer:port. Peer cannot be NULL. | 331 | /* Create client TCP socket connected to peer:port. Peer cannot be NULL. |
@@ -345,7 +353,7 @@ len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t | |||
345 | #define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), (port))) | 353 | #define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), (port))) |
346 | #define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port))) | 354 | #define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port))) |
347 | #endif | 355 | #endif |
348 | /* Assign sin[6]_port member if the socket is of corresponding type, | 356 | /* Assign sin[6]_port member if the socket is an AF_INET[6] one, |
349 | * otherwise no-op. Useful for ftp. | 357 | * otherwise no-op. Useful for ftp. |
350 | * NB: does NOT do htons() internally, just direct assignment. */ | 358 | * NB: does NOT do htons() internally, just direct assignment. */ |
351 | void set_nport(len_and_sockaddr *lsa, unsigned port); | 359 | void set_nport(len_and_sockaddr *lsa, unsigned port); |