21 #ifndef XAPIAN_INCLUDED_REMOTECONNECTION_H
22 #define XAPIAN_INCLUDED_REMOTECONNECTION_H
79 # if defined(SO_NOSIGPIPE) && !defined(__NetBSD__)
82 # define USE_SO_NOSIGPIPE
83 # elif defined MSG_NOSIGNAL
85 int send_flags = MSG_NOSIGNAL;
86 # define USE_MSG_NOSIGNAL
117 WSAOVERLAPPED overlapped;
123 DWORD calc_read_wait_msecs(
double end_time);
139 const std::string & context_ = std::string());
279 const std::string& context_ = std::string())
RemoteConnection which owns its own fd(s).
OwnedRemoteConnection(int fdin_, int fdout_, const std::string &context_=std::string())
Constructor.
~OwnedRemoteConnection()
Destructor.
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
void send_message(char type, std::string_view s, double end_time)
Send a message.
int fdin
The file descriptor used for reading.
std::string buffer
Buffer to hold unprocessed input.
const std::string & get_context() const
Return the context to report with errors.
RemoteConnection(const RemoteConnection &)
Don't allow copying.
int get_message_chunk(std::string &result, size_t at_least, double end_time)
Read a chunk of a message from fdin.
bool read_at_least(size_t min_len, double end_time)
Read until there are at least min_len bytes in buffer.
int fdout
The file descriptor used for writing.
int receive_file(const std::string &file, double end_time)
Save the contents of a message as a file.
off_t chunked_data_left
Remaining bytes of message data still to come over fdin for a chunked read.
void do_close()
Close the connection.
int get_read_fd() const
Return the underlying fd this remote connection reads from.
int get_message(std::string &result, double end_time)
Read one message from fdin.
void shutdown()
Shutdown the connection.
int sniff_next_message_type(double end_time)
Check what the next message type is.
int get_message_chunked(double end_time)
Prepare to read one message from fdin in chunks.
std::string context
The context to report with errors.
ssize_t send_or_write(const void *p, size_t n)
Helper which calls send() or write().
void operator=(const RemoteConnection &)
Don't allow assignment.
void send_file(char type, int fd, double end_time)
Send the contents of a file as a message.
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
Remote protocol version and message numbers.
include <sys/socket.h> with portability workarounds.
include <winsock2.h> but working around problems.