#include <tcpclient.h>
Public Member Functions | |
TcpClient (const std::string &hostname, int port, int msecs_timeout, int msecs_timeout_connect, bool writable) | |
Constructor. | |
~TcpClient () | |
Destructor. | |
Private Member Functions | |
void | operator= (const TcpClient &) |
Don't allow assignment. | |
TcpClient (const TcpClient &) | |
Don't allow copying. | |
Static Private Member Functions | |
static int | open_socket (const std::string &hostname, int port, int msecs_timeout_connect) |
Attempt to open a TCP/IP socket connection to xapian-tcpsrv. | |
static std::string | get_tcpcontext (const std::string &hostname, int port) |
Get a context string for use when constructing Xapian::NetworkError. |
Connects via TCP/IP to an instance of xapian-tcpsrv.
Definition at line 36 of file tcpclient.h.
TcpClient::TcpClient | ( | const TcpClient & | ) | [private] |
Don't allow copying.
TcpClient::TcpClient | ( | const std::string & | hostname, | |
int | port, | |||
int | msecs_timeout, | |||
int | msecs_timeout_connect, | |||
bool | writable | |||
) | [inline] |
Constructor.
Attempts to open a TCP/IP connection to xapian-tcpsrv running on port port of host hostname.
msecs_timeout_connect | Timeout for trying to connect (in milliseconds). | |
msecs_timeout | Timeout during communication after successfully connecting (in milliseconds). | |
writable | Is this a WritableDatabase? |
Definition at line 76 of file tcpclient.h.
TcpClient::~TcpClient | ( | ) |
void TcpClient::operator= | ( | const TcpClient & | ) | [private] |
Don't allow assignment.
int TcpClient::open_socket | ( | const std::string & | hostname, | |
int | port, | |||
int | msecs_timeout_connect | |||
) | [static, private] |
Attempt to open a TCP/IP socket connection to xapian-tcpsrv.
Connect to xapian-tcpsrv running on port port of host hostname. Give up trying to connect after msecs_timeout_connect milliseconds.
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, this method has been deliberately made "static".
Definition at line 49 of file tcpclient.cc.
References get_tcpcontext(), socket_errno, and SOCKLEN_T.
std::string TcpClient::get_tcpcontext | ( | const std::string & | hostname, | |
int | port | |||
) | [static, private] |
Get a context string for use when constructing Xapian::NetworkError.
Note: this method is used from constructors so has been made static to avoid problems with trying to use uninitialised member variables. In particular, it can't be made a virtual method of the base class.
Definition at line 43 of file tcpclient.cc.
References om_tostring().
Referenced by open_socket().