author | František Kučera <franta-hg@frantovo.cz> |
Thu, 18 Aug 2022 22:13:35 +0200 | |
branch | v_0 |
changeset 25 | de58479757e1 |
parent 24 | b668bd88ffa2 |
child 26 | 07949ba141b7 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* Relational pipes |
|
3 |
* Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, version 3 of the License. |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
#include <string> |
|
1
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
18 |
#include <cstring> |
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
19 |
#include <unistd.h> |
0 | 20 |
#include <stdexcept> |
1
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
21 |
#include <arpa/inet.h> |
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
22 |
#include <sys/types.h> |
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
23 |
#include <sys/socket.h> |
24 | 24 |
#include <sys/un.h> |
1
e3265afd1111
first version: TCP-only + fixed parameters
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
25 |
#include <netinet/in.h> |
2 | 26 |
#include <vector> |
3
e701e06ff561
add some factories: generic/template version
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
27 |
#include <memory> |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
28 |
#include <regex> |
10
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
29 |
#include <iostream> |
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
30 |
#include <netdb.h> |
2 | 31 |
|
32 |
#include "Socket.h" |
|
0 | 33 |
|
34 |
namespace relpipe { |
|
35 |
namespace out { |
|
36 |
namespace socket { |
|
37 |
||
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
38 |
using namespace relpipe::out::socket::options; |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
39 |
|
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
40 |
static const std::string findOption(SocketOptions options, std::string name, bool required = false, const std::string defaultValue = "") { |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
41 |
for (auto o : options) if (o.name == name) return o.value; |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
42 |
if (required) throw std::invalid_argument("Option " + name + " is required but was not found"); |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
43 |
else return defaultValue; |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
44 |
} |
3
e701e06ff561
add some factories: generic/template version
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
45 |
|
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
46 |
class FD { |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
47 |
private: |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
48 |
int fd; |
0 | 49 |
public: |
50 |
||
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
51 |
FD(int fd) : fd(fd) { |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
52 |
}; |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
53 |
|
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
54 |
virtual ~FD() { |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
55 |
close(fd); |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
56 |
} |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
57 |
|
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
58 |
int getFD() { |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
59 |
return fd; |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
60 |
} |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
61 |
}; |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
62 |
|
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
63 |
static void check(int result, std::string message) { |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
64 |
if (result == 0); // OK |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
65 |
else throw std::logic_error("Got error result: " + std::to_string(result) + " - " + message); |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
66 |
} |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
67 |
|
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
68 |
class AddressInfos { |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
69 |
private: |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
70 |
std::shared_ptr<addrinfo> addrInfo; |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
71 |
|
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
72 |
AddressInfos(addrinfo* addrInfo) : addrInfo(std::shared_ptr<addrinfo>(addrInfo, freeaddrinfo)) { |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
73 |
} |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
74 |
|
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
75 |
public: |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
76 |
|
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
77 |
virtual ~AddressInfos() { |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
78 |
} |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
79 |
|
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
80 |
class AddressInfo { |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
81 |
private: |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
82 |
std::shared_ptr<addrinfo> parent; // to avoid premature deletion of the whole structure |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
83 |
public: |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
84 |
const addrinfo * const ai; |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
85 |
|
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
86 |
AddressInfo(const addrinfo * const ai, std::shared_ptr<addrinfo> parent) : ai(ai), parent(parent) { |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
87 |
} |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
88 |
|
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
89 |
const std::string toString() const { |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
90 |
char buffer[INET6_ADDRSTRLEN] = {0}; |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
91 |
if (ai->ai_family == AF_INET) return inet_ntop(ai->ai_family, &((sockaddr_in const *) ai->ai_addr)->sin_addr, buffer, sizeof (buffer)); // TODO: check 0 result |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
92 |
else if (ai->ai_family == AF_INET6) return inet_ntop(ai->ai_family, &((sockaddr_in6 const *) ai->ai_addr)->sin6_addr, buffer, sizeof (buffer)); // TODO: check 0 result |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
93 |
else return "unknown address family: " + std::to_string(ai->ai_family); |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
94 |
} |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
95 |
}; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
96 |
|
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
97 |
static AddressInfos getAddressInfos(const std::string& host, const std::string& port, int socketType = SOCK_STREAM, int protocol = IPPROTO_TCP) { |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
98 |
struct addrinfo query; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
99 |
memset(&query, sizeof (query), 0); |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
100 |
query.ai_family = AF_UNSPEC; |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
101 |
query.ai_socktype = socketType; |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
102 |
query.ai_protocol = protocol; |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
103 |
query.ai_flags = AI_ALL; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
104 |
|
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
105 |
struct addrinfo* addrInfo; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
106 |
check(getaddrinfo(host.c_str(), port.c_str(), &query, &addrInfo), "getaddrinfo"); |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
107 |
|
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
108 |
return AddressInfos(addrInfo); |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
109 |
} |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
110 |
|
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
111 |
const std::size_t size() const { |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
112 |
std::size_t size = 0; |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
113 |
for (addrinfo* ai = addrInfo.get(); ai; ai = ai->ai_next) size++; |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
114 |
return size; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
115 |
} |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
116 |
|
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
117 |
const AddressInfo operator[](std::size_t index) const { |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
118 |
for (addrinfo* ai = addrInfo.get(); ai; index--) { |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
119 |
if (index == 0) return AddressInfo(ai, addrInfo); |
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
120 |
else ai = ai->ai_next; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
121 |
} |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
122 |
|
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
123 |
throw std::out_of_range("invalid index for AddressInfo: " + std::to_string(index)); |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
124 |
} |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
125 |
|
12
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
126 |
}; |
fcc5ed0fab9f
AddressInfos [] = addrinfo&
František Kučera <franta-hg@frantovo.cz>
parents:
11
diff
changeset
|
127 |
|
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
128 |
template<class SocketClass, class... MoreArgs> static std::shared_ptr<SocketClass> openClientSocket(const SocketOptions& options, int socketType, int protocol, MoreArgs... moreArgs) { |
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
129 |
AddressInfos remoteAddresses = AddressInfos::getAddressInfos( |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
130 |
findOption(options, OPTION_HOST, true), |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
131 |
findOption(options, OPTION_PORT, true), |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
132 |
socketType, |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
133 |
protocol); |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
134 |
|
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
135 |
return std::shared_ptr<SocketClass>(new SocketClass(remoteAddresses[0], moreArgs...)); |
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
136 |
} |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
137 |
|
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
138 |
class MSGSocket : public Socket { |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
139 |
protected: |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
140 |
FD socket; |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
141 |
|
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
142 |
void sendmsg(const std::string& message) { |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
143 |
iovec iov[1]; |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
144 |
msghdr msg = {}; |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
145 |
msg.msg_iov = iov; |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
146 |
msg.msg_iov[0].iov_base = (void*) message.c_str(); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
147 |
msg.msg_iov[0].iov_len = message.size(); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
148 |
msg.msg_iovlen = sizeof (iov) / sizeof (iov[0]); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
149 |
ssize_t written = ::sendmsg(socket.getFD(), &msg, 0); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
150 |
if (written != message.size()) throw std::logic_error("writing to the socket failed"); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
151 |
} |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
152 |
public: |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
153 |
|
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
154 |
MSGSocket(int socket) : socket(socket) { |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
155 |
} |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
156 |
|
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
157 |
void send(const std::string& message) { |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
158 |
sendmsg(message); |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
159 |
} |
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
160 |
|
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
161 |
}; |
24 | 162 |
|
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
163 |
class UDPClientSocket : public Socket { |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
164 |
private: |
16
63bb2c2038c7
work with single address
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
165 |
AddressInfos::AddressInfo remoteAddress; |
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
166 |
useconds_t delay = 0; |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
167 |
FD socket; |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
168 |
|
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
169 |
public: |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
170 |
|
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
171 |
UDPClientSocket(AddressInfos::AddressInfo remoteAddress) : remoteAddress(remoteAddress), socket(::socket(remoteAddress.ai->ai_family, remoteAddress.ai->ai_socktype, remoteAddress.ai->ai_protocol)) { |
13
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
172 |
} |
c29b13a659a7
AddressInfos [] = AddressInfo; UDP
František Kučera <franta-hg@frantovo.cz>
parents:
12
diff
changeset
|
173 |
|
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
174 |
static std::shared_ptr<Socket> open(const SocketOptions& options) { |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
175 |
auto socket = openClientSocket<UDPClientSocket>(options, SOCK_DGRAM, IPPROTO_UDP); |
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
176 |
socket->delay = std::stol(findOption(options, OPTION_DELAY, false, "0")); // TODO: Move to SocketHandler? Or delete. |
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
177 |
return socket; |
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
178 |
} |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
179 |
|
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
180 |
void send(const std::string& message) override { |
16
63bb2c2038c7
work with single address
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
181 |
auto ai = remoteAddress.ai; |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
182 |
sendto(socket.getFD(), message.c_str(), message.size(), 0, ai->ai_addr, ai->ai_addrlen); |
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
16
diff
changeset
|
183 |
if (delay) usleep(delay); |
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
184 |
} |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
185 |
|
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
186 |
const std::string receive() override { |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
187 |
// TODO: UDP receive() |
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
188 |
return "TODO: receive() a message"; |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
189 |
} |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
190 |
}; |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
191 |
|
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
192 |
class TCPClientSocket : public Socket { |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
193 |
private: |
16
63bb2c2038c7
work with single address
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
194 |
AddressInfos::AddressInfo remoteAddress; |
14
86feef4b6ee6
AddressInfos [] = AddressInfo; TCP
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
195 |
|
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
196 |
public: |
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
197 |
|
16
63bb2c2038c7
work with single address
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
198 |
TCPClientSocket(AddressInfos::AddressInfo remoteAddress) : remoteAddress(remoteAddress) { |
14
86feef4b6ee6
AddressInfos [] = AddressInfo; TCP
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
199 |
} |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
200 |
|
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
201 |
static std::shared_ptr<Socket> open(const SocketOptions& options) { |
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
202 |
return openClientSocket<TCPClientSocket>(options, SOCK_STREAM, IPPROTO_TCP); |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
203 |
} |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
204 |
|
2 | 205 |
void send(const std::string& message) override { |
16
63bb2c2038c7
work with single address
František Kučera <franta-hg@frantovo.cz>
parents:
15
diff
changeset
|
206 |
auto ai = remoteAddress.ai; |
14
86feef4b6ee6
AddressInfos [] = AddressInfo; TCP
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
207 |
FD s(::socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)); |
86feef4b6ee6
AddressInfos [] = AddressInfo; TCP
František Kučera <franta-hg@frantovo.cz>
parents:
13
diff
changeset
|
208 |
check(::connect(s.getFD(), ai->ai_addr, ai->ai_addrlen), "connect socket"); |
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
209 |
ssize_t written = ::write(s.getFD(), message.c_str(), message.size()); |
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
210 |
if (written != message.size()) throw std::logic_error("writing to the socket failed"); |
15
290c58261df9
template openClientSocket()
František Kučera <franta-hg@frantovo.cz>
parents:
14
diff
changeset
|
211 |
// TODO: partial writes, repeat |
2 | 212 |
} |
0 | 213 |
|
2 | 214 |
const std::string receive() override { |
215 |
// TODO: TCP receive() |
|
216 |
return "TODO: receive() a message"; |
|
0 | 217 |
} |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
218 |
}; |
0 | 219 |
|
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
220 |
class SCTPClientSocket : public MSGSocket { |
22 | 221 |
private: |
222 |
AddressInfos::AddressInfo remoteAddress; |
|
223 |
public: |
|
224 |
||
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
225 |
SCTPClientSocket(AddressInfos::AddressInfo remoteAddress) : remoteAddress(remoteAddress), MSGSocket(::socket(remoteAddress.ai->ai_family, remoteAddress.ai->ai_socktype, remoteAddress.ai->ai_protocol)) { |
22 | 226 |
} |
227 |
||
228 |
static std::shared_ptr<Socket> open(const SocketOptions& options) { |
|
23
4d97d58d40df
SCTP: sendmsg() only
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
229 |
auto socket = openClientSocket<SCTPClientSocket>(options, SOCK_STREAM, IPPROTO_SCTP); |
22 | 230 |
check(::connect(socket->socket.getFD(), socket->remoteAddress.ai->ai_addr, socket->remoteAddress.ai->ai_addrlen), "connect socket"); |
231 |
return socket; |
|
232 |
} |
|
233 |
||
234 |
const std::string receive() override { |
|
235 |
// TODO: SCTP receive() |
|
236 |
return "TODO: receive() a message"; |
|
237 |
} |
|
238 |
}; |
|
239 |
||
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
240 |
class UDSClientSocket : public MSGSocket { |
24 | 241 |
public: |
242 |
||
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
243 |
UDSClientSocket(int fd) : MSGSocket(fd) { |
24 | 244 |
} |
245 |
||
246 |
static std::shared_ptr<Socket> open(const SocketOptions& options) { |
|
247 |
struct sockaddr_un address; |
|
248 |
std::string path = findOption(options, OPTION_PATH); |
|
249 |
||
250 |
memset(&address, 0x00, sizeof (address)); |
|
251 |
address.sun_family = AF_UNIX; |
|
252 |
strncpy(address.sun_path, path.c_str(), path.size()); |
|
253 |
||
254 |
int fd = ::socket(AF_UNIX, SOCK_STREAM, 0); |
|
255 |
||
256 |
auto socket = std::make_shared<UDSClientSocket>(fd); |
|
257 |
check(::connect(socket->socket.getFD(), (const sockaddr*) &address, sizeof (address)), "connect socket"); |
|
258 |
||
259 |
||
260 |
// zjistíme UID, GID a PID klienta, který se připojil na náš unixový soket: |
|
261 |
struct ucred cr; |
|
262 |
socklen_t crLen = sizeof (cr); |
|
263 |
memset(&cr, 0x00, crLen); |
|
264 |
getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crLen); |
|
265 |
||
266 |
// při opakovaném volání vrací stále totéž: |
|
267 |
// memset(&cr, 0x00, sizeof (cr)); |
|
268 |
// getsockopt(spojeni, SOL_SOCKET, SO_PEERCRED, &cr, &crLen); |
|
269 |
||
270 |
printf("Přijato spojení\n"); |
|
271 |
printf(" FD = %d\n", fd); |
|
272 |
printf(" klientská cesta = %s\n", address.sun_path); // tohle je vždy prázdné |
|
273 |
printf(" klientský PID = %d\n", cr.pid); |
|
274 |
printf(" klientský UID = %d\n", cr.uid); |
|
275 |
printf(" klientský GID = %d\n", cr.gid); |
|
276 |
||
277 |
||
278 |
return socket; |
|
279 |
} |
|
280 |
||
281 |
void send(const std::string& message) override { |
|
25
de58479757e1
introduce common parent class MSGSocket for sockets using sendmsg()
František Kučera <franta-hg@frantovo.cz>
parents:
24
diff
changeset
|
282 |
sendmsg(message); |
24 | 283 |
} |
284 |
||
285 |
const std::string receive() override { |
|
286 |
// TODO: UDS receive() |
|
287 |
return "TODO: receive() a message"; |
|
288 |
} |
|
289 |
}; |
|
290 |
||
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
291 |
template<const char* protocol, const char* role, const char* mode, typename SocketClass> |
3
e701e06ff561
add some factories: generic/template version
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
292 |
class TemplateSocketFactory : public SocketFactory { |
2 | 293 |
public: |
294 |
||
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
295 |
bool canHandle(const SocketOptions& options) override { |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
296 |
return findOption(options, OPTION_PROTOCOL) == protocol |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
297 |
&& findOption(options, OPTION_ROLE) == role |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
298 |
&& findOption(options, OPTION_MODE) == mode; |
2 | 299 |
} |
300 |
||
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
301 |
std::shared_ptr<Socket> open(const SocketOptions& options) override { |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
302 |
return SocketClass::open(options); |
2 | 303 |
} |
3
e701e06ff561
add some factories: generic/template version
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
304 |
}; |
2 | 305 |
|
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
306 |
static std::vector<std::shared_ptr<SocketFactory>> factories |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
3
diff
changeset
|
307 |
{ |
9
de48b9278211
TCP and UDP client sockets - first version
František Kučera <franta-hg@frantovo.cz>
parents:
7
diff
changeset
|
308 |
std::make_shared<TemplateSocketFactory<PROTOCOL_TCP, ROLE_CLIENT, MODE_STREAM, TCPClientSocket >> (), |
10
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
309 |
std::make_shared<TemplateSocketFactory<PROTOCOL_TCP, ROLE_SERVER, MODE_STREAM, TCPClientSocket >> (), // TODO: correct class |
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
310 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDP, ROLE_CLIENT, MODE_DATAGRAM, UDPClientSocket >> (), |
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
311 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDP, ROLE_SERVER, MODE_DATAGRAM, UDPClientSocket >> (), // TODO: correct class |
23
4d97d58d40df
SCTP: sendmsg() only
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
312 |
std::make_shared<TemplateSocketFactory<PROTOCOL_SCTP, ROLE_CLIENT, MODE_STREAM, SCTPClientSocket >> (), |
4d97d58d40df
SCTP: sendmsg() only
František Kučera <franta-hg@frantovo.cz>
parents:
22
diff
changeset
|
313 |
std::make_shared<TemplateSocketFactory<PROTOCOL_SCTP, ROLE_CLIENT, MODE_DATAGRAM, SCTPClientSocket >> (), |
21
1c6c86697837
UDP: reuse socket; SCTP: first version
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
314 |
std::make_shared<TemplateSocketFactory<PROTOCOL_SCTP, ROLE_SERVER, MODE_STREAM, UDPClientSocket >> (), // TODO: do we need a stream-mode SCTP? |
10
6a6b93507856
use getaddrinfo(), inet_ntop(), some DNS and IPv4 support
František Kučera <franta-hg@frantovo.cz>
parents:
9
diff
changeset
|
315 |
std::make_shared<TemplateSocketFactory<PROTOCOL_SCTP, ROLE_SERVER, MODE_DATAGRAM, UDPClientSocket >> (), // TODO: correct class |
24 | 316 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDS, ROLE_CLIENT, MODE_STREAM, UDSClientSocket >> (), // TODO: correct class |
317 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDS, ROLE_CLIENT, MODE_DATAGRAM, UDSClientSocket >> (), // TODO: correct class |
|
318 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDS, ROLE_SERVER, MODE_STREAM, UDSClientSocket >> (), // TODO: correct class |
|
319 |
std::make_shared<TemplateSocketFactory<PROTOCOL_UDS, ROLE_SERVER, MODE_DATAGRAM, UDSClientSocket >> (), // TODO: correct class |
|
3
e701e06ff561
add some factories: generic/template version
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
320 |
}; |
2 | 321 |
|
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
322 |
std::shared_ptr<SocketFactory> SocketFactory::find(const SocketOptions& options) { |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
323 |
for (auto f : factories) if (f->canHandle(options)) return f; |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
324 |
throw std::logic_error("Unable to find a SocketFactory"); // TODO: add relevant options? |
2 | 325 |
} |
326 |
||
327 |
||
0 | 328 |
} |
329 |
} |
|
330 |
} |