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) 110 # define CLOSESOCKET(S) close(S) 120 #define C(X) ((X) < 0 ? 2 : 1) 134 #ifdef EAI_ADDRFAMILY 207 # if defined(SO_NOSIGPIPE) && !defined(__NetBSD__) 210 # define USE_SO_NOSIGPIPE 211 # elif defined MSG_NOSIGNAL 213 int send_flags = MSG_NOSIGNAL;
214 # define USE_MSG_NOSIGNAL 236 bool read_at_least(
size_t min_len,
double end_time);
245 WSAOVERLAPPED overlapped;
251 DWORD calc_read_wait_msecs(
double end_time);
254 ssize_t send_or_write(
const void* p,
size_t n);
267 const std::string & context_ = std::string());
278 bool ready_to_read()
const;
297 int sniff_next_message_type(
double end_time);
309 int get_message(std::string &result,
double end_time);
327 int get_message_chunked(
double end_time);
349 int get_message_chunk(std::string &result,
size_t at_least,
363 int receive_file(
const std::string &file,
double end_time);
374 void send_message(
char type,
const std::string & s,
double end_time);
385 void send_file(
char type,
int fd,
double end_time);
407 const std::string& context_ = std::string())
416 #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.
include <sys/socket.h> with portability workarounds.
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.