xapian-core  1.4.27
Functions
socket_utils.h File Reference

Socket handling utilities. More...

#include "safeunistd.h"
+ Include dependency graph for socket_utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void close_fd_or_socket (int fd)
 
void set_socket_timeouts (int fd, double timeout)
 Attempt to set socket-level timeouts. More...
 

Detailed Description

Socket handling utilities.

Definition in file socket_utils.h.

Function Documentation

◆ close_fd_or_socket()

void close_fd_or_socket ( int  fd)
inline

Definition at line 38 of file socket_utils.h.

References close(), and set_socket_timeouts().

Referenced by RemoteConnection::do_close().

◆ set_socket_timeouts()

void set_socket_timeouts ( int  fd,
double  timeout 
)

Attempt to set socket-level timeouts.

These aren't supported by all platforms, and some platforms allow them to set but ignore them, so we can't easily report failure.

Also sets SO_KEEPALIVE (if supported), which should ensure a stuck connection will eventually time out, though it may take up to ~2 hours.

Definition at line 64 of file socket_utils.cc.

References RealTime::to_timeval(), and usual.

Referenced by close_fd_or_socket().