xapian-core  1.4.25
socket_utils.cc File Reference

Socket handling utilities. More...

#include <config.h>
#include "socket_utils.h"
#include <limits>
#include "realtime.h"
#include "safesyssocket.h"
+ Include dependency graph for socket_utils.cc:

Go to the source code of this file.


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.cc.

Function Documentation

◆ 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().