21 #ifndef XAPIAN_INCLUDED_REMOTECONNECTION_H 22 #define XAPIAN_INCLUDED_REMOTECONNECTION_H 49 struct WinsockInitializer {
50 WinsockInitializer() {
52 int wsaerror = WSAStartup(MAKEWORD(2, 2), &wsadata);
61 ~WinsockInitializer() {
75 int wsa_err = WSAGetLastError();
78 case WSAEADDRINUSE:
return EADDRINUSE;
81 case WSAETIMEDOUT:
return ETIMEDOUT;
84 case WSAEINPROGRESS:
return EINPROGRESS;
86 default:
return wsa_err;
94 # define EADDRINUSE WSAEADDRINUSE 97 # define ETIMEDOUT WSAETIMEDOUT 100 # define EINPROGRESS WSAEINPROGRESS 105 # define CLOSESOCKET(S) closesocket(S) 109 # define CLOSESOCKET(S) close(S) 119 #define C(X) ((X) < 0 ? 2 : 1) 133 #ifdef EAI_ADDRFAMILY 208 bool read_at_least(
size_t min_len,
double end_time);
216 WSAOVERLAPPED overlapped;
222 DWORD calc_read_wait_msecs(
double end_time);
235 const std::string & context_ = std::string());
246 bool ready_to_read()
const;
265 int sniff_next_message_type(
double end_time);
277 int get_message(std::string &result,
double end_time);
295 int get_message_chunked(
double end_time);
317 int get_message_chunk(std::string &result,
size_t at_least,
331 int receive_file(
const std::string &file,
double end_time);
342 void send_message(
char type,
const std::string & s,
double end_time);
353 void send_file(
char type,
int fd,
double end_time);
375 const std::string& context_ = std::string())
384 #endif // XAPIAN_INCLUDED_REMOTECONNECTION_H A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
OwnedRemoteConnection(int fdin_, int fdout_, const std::string &context_=std::string())
Constructor.
off_t chunked_data_left
Remaining bytes of message data still to come over fdin for a chunked read.
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
include <netdb.h>, with portability workarounds.
std::string context
The context to report with errors.
Remote protocol version and message numbers.
Hierarchy of classes which Xapian can throw as exceptions.
int fdin
The file descriptor used for reading.
include <winsock2.h> but working around problems.
std::string buffer
Buffer to hold unprocessed input.
RemoteConnection which owns its own fd(s).
~OwnedRemoteConnection()
Destructor.
Indicates a problem communicating with a remote database.
<unistd.h>, but with compat.
int fdout
The file descriptor used for writing.