aboutsummaryrefslogtreecommitdiffstats
path: root/common/network/TcpSocket.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/network/TcpSocket.cxx')
-rw-r--r--common/network/TcpSocket.cxx26
1 files changed, 13 insertions, 13 deletions
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 455df749..bf603755 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -85,15 +85,15 @@ int network::findFreeTcpPort (void)
addr.sin_addr.s_addr = INADDR_ANY;
if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
- throw SocketException ("unable to create socket", errorNumber);
+ throw socket_error("unable to create socket", errorNumber);
addr.sin_port = 0;
if (bind (sock, (struct sockaddr *)&addr, sizeof (addr)) < 0)
- throw SocketException ("unable to find free port", errorNumber);
+ throw socket_error("unable to find free port", errorNumber);
socklen_t n = sizeof(addr);
if (getsockname (sock, (struct sockaddr *)&addr, &n) < 0)
- throw SocketException ("unable to get port number", errorNumber);
+ throw socket_error("unable to get port number", errorNumber);
closesocket (sock);
return ntohs(addr.sin_port);
@@ -137,7 +137,7 @@ TcpSocket::TcpSocket(const char *host, int port)
hints.ai_next = nullptr;
if ((result = getaddrinfo(host, nullptr, &hints, &ai)) != 0) {
- throw GAIException("unable to resolve host by name", result);
+ throw getaddrinfo_error("unable to resolve host by name", result);
}
sock = -1;
@@ -178,7 +178,7 @@ TcpSocket::TcpSocket(const char *host, int port)
if (sock == -1) {
err = errorNumber;
freeaddrinfo(ai);
- throw SocketException("unable to create socket", err);
+ throw socket_error("unable to create socket", err);
}
/* Attempt to connect to the remote host */
@@ -205,7 +205,7 @@ TcpSocket::TcpSocket(const char *host, int port)
if (err == 0)
throw std::runtime_error("No useful address for host");
else
- throw SocketException("unable to connect to socket", err);
+ throw socket_error("unable to connect to socket", err);
}
// Take proper ownership of the socket
@@ -302,7 +302,7 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr,
int sock;
if ((sock = socket (listenaddr->sa_family, SOCK_STREAM, 0)) < 0)
- throw SocketException("unable to create listening socket", errorNumber);
+ throw socket_error("unable to create listening socket", errorNumber);
memcpy (&sa, listenaddr, listenaddrlen);
#ifdef IPV6_V6ONLY
@@ -310,7 +310,7 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr,
if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&one, sizeof(one))) {
int e = errorNumber;
closesocket(sock);
- throw SocketException("unable to set IPV6_V6ONLY", e);
+ throw socket_error("unable to set IPV6_V6ONLY", e);
}
}
#endif /* defined(IPV6_V6ONLY) */
@@ -328,14 +328,14 @@ TcpListener::TcpListener(const struct sockaddr *listenaddr,
(char *)&one, sizeof(one)) < 0) {
int e = errorNumber;
closesocket(sock);
- throw SocketException("unable to create listening socket", e);
+ throw socket_error("unable to create listening socket", e);
}
#endif
if (bind(sock, &sa.u.sa, listenaddrlen) == -1) {
int e = errorNumber;
closesocket(sock);
- throw SocketException("failed to bind socket", e);
+ throw socket_error("failed to bind socket", e);
}
listen(sock);
@@ -446,7 +446,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
snprintf (service, sizeof (service) - 1, "%d", port);
service[sizeof (service) - 1] = '\0';
if ((result = getaddrinfo(addr, service, &hints, &ai)) != 0)
- throw GAIException("unable to resolve listening address", result);
+ throw getaddrinfo_error("unable to resolve listening address", result);
try {
createTcpListeners(listeners, ai);
@@ -485,7 +485,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
try {
new_listeners.push_back(new TcpListener(current->ai_addr,
current->ai_addrlen));
- } catch (SocketException& e) {
+ } catch (socket_error& e) {
// Ignore this if it is due to lack of address family support on
// the interface or on the system
if (e.err != EADDRNOTAVAIL && e.err != EAFNOSUPPORT) {
@@ -633,7 +633,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
}
if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) {
- throw GAIException("unable to resolve host by name", result);
+ throw getaddrinfo_error("unable to resolve host by name", result);
}
memcpy (&pattern.address.u.sa, ai->ai_addr, ai->ai_addrlen);