2 * @brief TCP/IP replication client class.
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"
26 #include "xapian/visibility.h"
27 #include "api/replication.h"
30 # define SOCKET_INITIALIZER_MIXIN : private WinsockInitializer
32 # define SOCKET_INITIALIZER_MIXIN
35 /// TCP/IP replication client class.
36 class XAPIAN_VISIBILITY_DEFAULT ReplicateTcpClient SOCKET_INITIALIZER_MIXIN
{
37 /// Don't allow assignment.
38 void operator=(const ReplicateTcpClient
&);
40 /// Don't allow copying.
41 ReplicateTcpClient(const ReplicateTcpClient
&);
46 /// Write-only connection to the server.
47 OwnedRemoteConnection remconn
;
49 /** Attempt to open a TCP/IP socket connection to a replication server.
51 * Connect to replication server running on port @a port of host @a hostname.
52 * Give up trying to connect after @a timeout_connect seconds.
54 * Note: this method is called early on during class construction before
55 * any member variables or even the base class have been initialised.
56 * To help avoid accidentally trying to use member variables or call other
57 * methods which do, this method has been deliberately made "static".
59 static int open_socket(const std::string
& hostname
, int port
,
60 double timeout_connect
);
65 * Connect to replication server running on port @a port of host @a hostname.
66 * Give up trying to connect after @a timeout_connect seconds.
68 * @param timeout_connect Timeout for trying to connect (in seconds).
69 * @param socket_timeout Socket timeout (in seconds); 0 for no timeout.
71 ReplicateTcpClient(const std::string
& hostname
, int port
,
72 double timeout_connect
, double socket_timeout
);
74 void update_from_master(const std::string
& path
,
75 const std::string
& remotedb
,
76 Xapian::ReplicationInfo
& info
,
77 double reader_close_time
,
81 ~ReplicateTcpClient();
84 #endif // XAPIAN_INCLUDED_REPLICATETCPCLIENT_H