xapian-core  2.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SOCKET_INITIALIZER_MIXIN Class Referenceabstract

TCP/IP replication client class. More...

#include <replicatetcpclient.h>

+ Collaboration diagram for SOCKET_INITIALIZER_MIXIN:

Public Member Functions

 ReplicateTcpClient (const std::string &hostname, int port, double timeout_connect, double socket_timeout)
 Constructor. More...
 
void update_from_master (const std::string &path, const std::string &remotedb, Xapian::ReplicationInfo &info, double reader_close_time, bool force_copy)
 
 ~ReplicateTcpClient ()
 Destructor. More...
 
 TcpServer (const std::string &host, int port, bool tcp_nodelay, bool verbose_)
 Construct a TcpServer and start listening for connections. More...
 
 ~TcpServer ()
 Destructor. More...
 
void run ()
 Accept connections and service requests indefinitely. More...
 
void run_once ()
 Accept a single connection, service requests on it, then stop. More...
 
bool get_verbose () const
 Should we produce output when connections are made or lost? More...
 
virtual void handle_one_connection (int socket)=0
 Handle a single connection on an already connected socket. More...
 

Protected Member Functions

int accept_connection ()
 Accept a connection and return the file descriptor for it. More...
 

Protected Attributes

bool verbose
 Should we produce output when connections are made or lost? More...
 

Private Member Functions

void operator= (const ReplicateTcpClient &)
 Don't allow assignment. More...
 
 ReplicateTcpClient (const ReplicateTcpClient &)
 Don't allow copying. More...
 
TcpServeroperator= (const TcpServer &)=delete
 Don't allow assignment. More...
 
 TcpServer (const TcpServer &)=delete
 Don't allow copying. More...
 

Static Private Member Functions

static int open_socket (const std::string &hostname, int port, double timeout_connect)
 Attempt to open a TCP/IP socket connection to a replication server. More...
 

Private Attributes

int socket
 The socket fd. More...
 
OwnedRemoteConnection remconn
 Write-only connection to the server. More...
 
int listener
 The socket we're listening on. More...
 

Detailed Description

TCP/IP replication client class.

Generic TCP/IP socket based server base class.

Definition at line 37 of file replicatetcpclient.h.

Constructor & Destructor Documentation

◆ ~ReplicateTcpClient()

SOCKET_INITIALIZER_MIXIN::~ReplicateTcpClient ( )

Destructor.

◆ ~TcpServer()

SOCKET_INITIALIZER_MIXIN::~TcpServer ( )

Destructor.

Note: We don't need a virtual destructor despite having a virtual method as we don't ever delete a subclass using a pointer to the base class.

Member Function Documentation

◆ accept_connection()

int SOCKET_INITIALIZER_MIXIN::accept_connection ( )
protected

Accept a connection and return the file descriptor for it.

◆ get_verbose()

bool SOCKET_INITIALIZER_MIXIN::get_verbose ( ) const
inline

Should we produce output when connections are made or lost?

Definition at line 87 of file tcpserver.h.

References verbose.

◆ handle_one_connection()

virtual void SOCKET_INITIALIZER_MIXIN::handle_one_connection ( int  socket)
pure virtual

Handle a single connection on an already connected socket.

◆ open_socket()

static int SOCKET_INITIALIZER_MIXIN::open_socket ( const std::string &  hostname,
int  port,
double  timeout_connect 
)
staticprivate

Attempt to open a TCP/IP socket connection to a replication server.

Connect to replication server running on port port of host hostname. Give up trying to connect after timeout_connect seconds.

Note: this method is called early on during class construction before any member variables or even the base class have been initialised. To help avoid accidentally trying to use member variables or call other methods which do, this method has been deliberately made "static".

◆ operator=() [1/2]

void SOCKET_INITIALIZER_MIXIN::operator= ( const ReplicateTcpClient )
private

Don't allow assignment.

◆ operator=() [2/2]

TcpServer& SOCKET_INITIALIZER_MIXIN::operator= ( const TcpServer )
privatedelete

Don't allow assignment.

◆ ReplicateTcpClient() [1/2]

SOCKET_INITIALIZER_MIXIN::ReplicateTcpClient ( const ReplicateTcpClient &  )
private

Don't allow copying.

◆ ReplicateTcpClient() [2/2]

SOCKET_INITIALIZER_MIXIN::ReplicateTcpClient ( const std::string &  hostname,
int  port,
double  timeout_connect,
double  socket_timeout 
)

Constructor.

Connect to replication server running on port port of host hostname. Give up trying to connect after timeout_connect seconds.

Parameters
timeout_connectTimeout for trying to connect (in seconds).
socket_timeoutSocket timeout (in seconds); 0 for no timeout.

◆ run()

void SOCKET_INITIALIZER_MIXIN::run ( )

Accept connections and service requests indefinitely.

This method runs the TcpServer as a daemon which accepts a connection and forks itself (or creates a new thread under Windows) to serve the request while continuing to listen for more connections.

◆ run_once()

void SOCKET_INITIALIZER_MIXIN::run_once ( )

Accept a single connection, service requests on it, then stop.


◆ TcpServer() [1/2]

SOCKET_INITIALIZER_MIXIN::TcpServer ( const std::string &  host,
int  port,
bool  tcp_nodelay,
bool  verbose_ 
)

Construct a TcpServer and start listening for connections.

Parameters
hostThe hostname or address for the interface to listen on (or "" to listen on all interfaces).
portThe TCP port number to listen on.
tcp_nodelayIf true, enable TCP_NODELAY option.
verboseShould we produce output when connections are made or lost?

◆ TcpServer() [2/2]

SOCKET_INITIALIZER_MIXIN::TcpServer ( const TcpServer &  )
privatedelete

Don't allow copying.

◆ update_from_master()

void SOCKET_INITIALIZER_MIXIN::update_from_master ( const std::string &  path,
const std::string &  remotedb,
Xapian::ReplicationInfo info,
double  reader_close_time,
bool  force_copy 
)

Member Data Documentation

◆ listener

int SOCKET_INITIALIZER_MIXIN::listener
private

The socket we're listening on.

Definition at line 44 of file tcpserver.h.

◆ remconn

OwnedRemoteConnection SOCKET_INITIALIZER_MIXIN::remconn
private

Write-only connection to the server.

Definition at line 48 of file replicatetcpclient.h.

◆ socket

int SOCKET_INITIALIZER_MIXIN::socket
private

The socket fd.

Definition at line 45 of file replicatetcpclient.h.

◆ verbose

bool SOCKET_INITIALIZER_MIXIN::verbose
protected

Should we produce output when connections are made or lost?

Definition at line 48 of file tcpserver.h.


The documentation for this class was generated from the following files: