00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include "remotetcpclient.h"
00024
00025 #include <xapian/error.h>
00026
00027 #include "str.h"
00028 #include "tcpclient.h"
00029
00030 using namespace std;
00031
00032 int
00033 RemoteTcpClient::open_socket(const string & hostname, int port,
00034 double timeout_connect)
00035 {
00036
00037 try {
00038 return TcpClient::open_socket(hostname, port, timeout_connect, true);
00039 } catch (const Xapian::NetworkTimeoutError & e) {
00040 throw Xapian::NetworkTimeoutError(e.get_msg(), get_tcpcontext(hostname, port),
00041 e.get_error_string());
00042 } catch (const Xapian::NetworkError & e) {
00043 throw Xapian::NetworkError(e.get_msg(), get_tcpcontext(hostname, port),
00044 e.get_error_string());
00045 }
00046 }
00047
00048 string
00049 RemoteTcpClient::get_tcpcontext(const string & hostname, int port)
00050 {
00051 string result("remote:tcp(");
00052 result += hostname;
00053 result += ':';
00054 result += str(port);
00055 result += ')';
00056 return result;
00057 }
00058
00059 RemoteTcpClient::~RemoteTcpClient()
00060 {
00061 do_close();
00062 }