diff options
author | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-09-16 15:52:39 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-09-16 15:52:39 +0200 |
commit | d16b3bc0c93452a4be7d06525793ac5190e38031 (patch) | |
tree | 8df8fd248b5b64c57a96b4da03506318f4d29956 /src/pgm_socket.cpp | |
parent | 35c58dc7331e3c5033b16829dff40437efe97a81 (diff) | |
parent | 10dd8c53460a28849aacf7d2e24b63d7fae11ae0 (diff) |
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'src/pgm_socket.cpp')
-rw-r--r-- | src/pgm_socket.cpp | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp index 315b43e..8ceff6c 100644 --- a/src/pgm_socket.cpp +++ b/src/pgm_socket.cpp @@ -68,24 +68,12 @@ zmq::pgm_socket_t::pgm_socket_t (bool receiver_, const options_t &options_) : } -int zmq::pgm_socket_t::init (const char *network_) +int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_) { - // Check if we are encapsulating into UDP, natwork string has to - // start with udp:. - const char *network_ptr = network_; - - if (strlen (network_) >= 4 && network_ [0] == 'u' && - network_ [1] == 'd' && network_ [2] == 'p' && - network_ [3] == ':') { - - // Shift interface_ptr after ':'. - network_ptr += 4; - - udp_encapsulation = true; - } + udp_encapsulation = udp_encapsulation_; // Parse port number. - const char *port_delim = strchr (network_ptr, ':'); + const char *port_delim = strchr (network_, ':'); if (!port_delim) { errno = EINVAL; return -1; @@ -93,20 +81,13 @@ int zmq::pgm_socket_t::init (const char *network_) port_number = atoi (port_delim + 1); - // Store interface string. - if (port_delim <= network_ptr) { - errno = EINVAL; - return -1; - } - - if (port_delim - network_ptr >= (int) sizeof (network) - 1) { + if (port_delim - network_ >= (int) sizeof (network) - 1) { errno = EINVAL; return -1; } memset (network, '\0', sizeof (network)); - memcpy (network, network_ptr, port_delim - network_ptr); - + memcpy (network, network_, port_delim - network_); zmq_log (1, "parsed: network %s, port %i, udp encaps. %s, %s(%i)\n", network, port_number, udp_encapsulation ? "yes" : "no", @@ -364,7 +345,7 @@ int zmq::pgm_socket_t::open_transport (void) return -1; } - zmq_log (1, "Preallocated %i slices in TX window. %s(%i)\n", + zmq_log (2, "Preallocated %i slices in TX window. %s(%i)\n", to_preallocate, __FILE__, __LINE__); // Set interval of background SPM packets [us]. @@ -611,7 +592,7 @@ ssize_t zmq::pgm_socket_t::receive (void **raw_data_) // Catch the rest of the errors. if (nbytes_rec <= 0) { - zmq_log (1, "received %i B, errno %i, %s(%i)", (int)nbytes_rec, + zmq_log (2, "received %i B, errno %i, %s(%i)", (int)nbytes_rec, errno, __FILE__, __LINE__); errno_assert (nbytes_rec > 0); } |