Update to Unicode 16.0.0
[xapian.git] / xapian-core / net / replicatetcpclient.h
blob209e2f8942bbce7920f63d9bad9afef60065b24f
1 /** @file
2 * @brief TCP/IP replication client class.
3 */
4 /* Copyright (C) 2008,2010,2011,2015 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_REPLICATETCPCLIENT_H
22 #define XAPIAN_INCLUDED_REPLICATETCPCLIENT_H
24 #include "remoteconnection.h"
25 #include "socket_utils.h"
27 #include "xapian/visibility.h"
28 #include "api/replication.h"
30 #ifdef __WIN32__
31 # define SOCKET_INITIALIZER_MIXIN : private WinsockInitializer
32 #else
33 # define SOCKET_INITIALIZER_MIXIN
34 #endif
36 /// TCP/IP replication client class.
37 class XAPIAN_VISIBILITY_DEFAULT ReplicateTcpClient SOCKET_INITIALIZER_MIXIN {
38 /// Don't allow assignment.
39 void operator=(const ReplicateTcpClient &);
41 /// Don't allow copying.
42 ReplicateTcpClient(const ReplicateTcpClient &);
44 /// The socket fd.
45 int socket;
47 /// Write-only connection to the server.
48 OwnedRemoteConnection remconn;
50 /** Attempt to open a TCP/IP socket connection to a replication server.
52 * Connect to replication server running on port @a port of host @a hostname.
53 * Give up trying to connect after @a timeout_connect seconds.
55 * Note: this method is called early on during class construction before
56 * any member variables or even the base class have been initialised.
57 * To help avoid accidentally trying to use member variables or call other
58 * methods which do, this method has been deliberately made "static".
60 XAPIAN_VISIBILITY_INTERNAL
61 static int open_socket(const std::string & hostname, int port,
62 double timeout_connect);
64 public:
65 /** Constructor.
67 * Connect to replication server running on port @a port of host @a hostname.
68 * Give up trying to connect after @a timeout_connect seconds.
70 * @param timeout_connect Timeout for trying to connect (in seconds).
71 * @param socket_timeout Socket timeout (in seconds); 0 for no timeout.
73 ReplicateTcpClient(const std::string & hostname, int port,
74 double timeout_connect, double socket_timeout);
76 void update_from_master(const std::string & path,
77 const std::string & remotedb,
78 Xapian::ReplicationInfo & info,
79 double reader_close_time,
80 bool force_copy);
82 /** Destructor. */
83 ~ReplicateTcpClient();
86 #endif // XAPIAN_INCLUDED_REPLICATETCPCLIENT_H