summaryrefslogtreecommitdiff
path: root/src/socket_base.cpp
diff options
context:
space:
mode:
authorDouglas Young <rcxdude@gmail.com>2012-05-07 23:20:57 +0100
committerMartin Sustrik <sustrik@250bpm.com>2012-05-09 07:50:19 +0200
commit0abe1093ad8f89e562ea583a18e8c4d79a2ff2b2 (patch)
tree3b5edbfa6ac715f777678098cc96e09430ebe9c3 /src/socket_base.cpp
parent1dbcf1a01f0bb704db85d3117baafe86ce4d2d8e (diff)
Return an error on invalid (e)pgm:// connection
This prevents the long-standing issue of an invalid pgm or epgm connection string from causing an assert when the connection is attempted and fails.
Diffstat (limited to 'src/socket_base.cpp')
-rw-r--r--src/socket_base.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 8ee8bd3..f1e7fca 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -34,6 +34,9 @@
#else
#include <unistd.h>
#endif
+#ifdef XS_HAVE_OPENPGM
+#include "pgm_socket.hpp"
+#endif
#include "socket_base.hpp"
#include "tcp_listener.hpp"
@@ -508,6 +511,18 @@ int xs::socket_base_t::connect (const char *addr_)
}
}
+#ifdef XS_HAVE_OPENPGM
+ if (protocol == "pgm" || protocol == "epgm") {
+ struct pgm_addrinfo_t *res = NULL;
+ uint16_t port_number = 0;
+ int rc = pgm_socket_t::init_address(address.c_str(), &res, &port_number);
+ if (res != NULL)
+ pgm_freeaddrinfo (res);
+ if (rc != 0 || port_number == 0)
+ return -1;
+ }
+#endif
+
// Create session.
session_base_t *session = session_base_t::create (thread, true, this,
options, protocol.c_str (), address.c_str ());