xapian-core  2.0.0
remotetcpclient.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2008,2010,2024 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include "remotetcpclient.h"
24 
25 #include <xapian/error.h>
26 
27 #include "str.h"
28 #include "tcpclient.h"
29 
30 using namespace std;
31 
32 pair<int, string>
33 RemoteTcpClient::open_socket(string_view hostname, int port,
34  double timeout_connect)
35 {
36  // Build a context string for use when constructing Xapian::NetworkError.
37  string context{"remote:tcp("};
38  context += hostname;
39  context += ':';
40  context += str(port);
41  context += ')';
42  return {TcpClient::open_socket(hostname, port, timeout_connect, true,
43  context),
44  context};
45 }
46 
48 {
49  try {
50  do_close();
51  } catch (...) {
52  }
53 }
static std::pair< int, std::string > open_socket(std::string_view hostname, int port, double timeout_connect)
Attempt to open a TCP/IP socket connection to xapian-tcpsrv.
~RemoteTcpClient()
Destructor.
Hierarchy of classes which Xapian can throw as exceptions.
int open_socket(std::string_view hostname, int port, double timeout_connect, bool tcp_nodelay, const std::string &context)
Attempt to open a TCP/IP socket connection to a server.
Definition: tcpclient.cc:51
string str(int value)
Convert int to std::string.
Definition: str.cc:91
TCP/IP socket based RemoteDatabase implementation.
Convert types to std::string.
Open a TCP connection to a server.