Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
0bf1d026
Commit
0bf1d026
authored
Jun 08, 2012
by
Ian Barber
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/zeromq/libzmq
parents
67497a26
b0792ec7
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
180 additions
and
94 deletions
+180
-94
zmq.h
include/zmq.h
+2
-2
Makefile.am
src/Makefile.am
+2
-0
ip.cpp
src/ip.cpp
+0
-83
ip.hpp
src/ip.hpp
+0
-6
ipc_listener.cpp
src/ipc_listener.cpp
+4
-0
pgm_socket.cpp
src/pgm_socket.cpp
+0
-1
stream_engine.cpp
src/stream_engine.cpp
+1
-1
tcp.cpp
src/tcp.cpp
+122
-0
tcp.hpp
src/tcp.hpp
+38
-0
tcp_connecter.cpp
src/tcp_connecter.cpp
+1
-0
tcp_listener.cpp
src/tcp_listener.cpp
+9
-0
test_connect_resolve.cpp
tests/test_connect_resolve.cpp
+1
-1
No files found.
include/zmq.h
View file @
0bf1d026
...
...
@@ -59,8 +59,8 @@ extern "C" {
/* Version macros for compile-time API version detection */
#define ZMQ_VERSION_MAJOR 3
#define ZMQ_VERSION_MINOR
1
#define ZMQ_VERSION_PATCH
1
#define ZMQ_VERSION_MINOR
3
#define ZMQ_VERSION_PATCH
0
#define ZMQ_MAKE_VERSION(major, minor, patch) \
((major) * 10000 + (minor) * 100 + (patch))
...
...
src/Makefile.am
View file @
0bf1d026
...
...
@@ -65,6 +65,7 @@ libzmq_la_SOURCES = \
stdint.hpp
\
stream_engine.hpp
\
sub.hpp
\
tcp.hpp
\
tcp_address.hpp
\
tcp_connecter.hpp
\
tcp_listener.hpp
\
...
...
@@ -123,6 +124,7 @@ libzmq_la_SOURCES = \
socket_base.cpp
\
stream_engine.cpp
\
sub.cpp
\
tcp.cpp
\
tcp_address.cpp
\
tcp_connecter.cpp
\
tcp_listener.cpp
\
...
...
src/ip.cpp
View file @
0bf1d026
...
...
@@ -66,89 +66,6 @@ zmq::fd_t zmq::open_socket (int domain_, int type_, int protocol_)
return
s
;
}
void
zmq
::
tune_tcp_socket
(
fd_t
s_
)
{
// Disable Nagle's algorithm. We are doing data batching on 0MQ level,
// so using Nagle wouldn't improve throughput in anyway, but it would
// hurt latency.
int
nodelay
=
1
;
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
nodelay
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
#ifdef ZMQ_HAVE_OPENVMS
// Disable delayed acknowledgements as they hurt latency is serious manner.
int
nodelack
=
1
;
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_NODELACK
,
(
char
*
)
&
nodelack
,
sizeof
(
int
));
errno_assert
(
rc
!=
SOCKET_ERROR
);
#endif
}
void
zmq
::
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
)
{
// Tuning TCP keep-alives if platform allows it
// All values = -1 means skip and leave it for OS
#ifdef ZMQ_HAVE_SO_KEEPALIVE
if
(
keepalive_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
char
*
)
&
keepalive_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
#ifdef ZMQ_HAVE_TCP_KEEPCNT
if
(
keepalive_cnt_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPCNT
,
&
keepalive_cnt_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPCNT
#ifdef ZMQ_HAVE_TCP_KEEPIDLE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPIDLE
,
&
keepalive_idle_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#else // ZMQ_HAVE_TCP_KEEPIDLE
#ifdef ZMQ_HAVE_TCP_KEEPALIVE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPALIVE
,
&
keepalive_idle_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPALIVE
#endif // ZMQ_HAVE_TCP_KEEPIDLE
#ifdef ZMQ_HAVE_TCP_KEEPINTVL
if
(
keepalive_intvl_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPINTVL
,
&
keepalive_intvl_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPINTVL
}
#endif // ZMQ_HAVE_SO_KEEPALIVE
}
void
zmq
::
unblock_socket
(
fd_t
s_
)
{
#ifdef ZMQ_HAVE_WINDOWS
...
...
src/ip.hpp
View file @
0bf1d026
...
...
@@ -30,12 +30,6 @@ namespace zmq
// Same as socket(2), but allows for transparent tweaking the options.
fd_t
open_socket
(
int
domain_
,
int
type_
,
int
protocol_
);
// Tunes the supplied TCP socket for the best latency.
void
tune_tcp_socket
(
fd_t
s_
);
// Tunes TCP keep-alives
void
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
);
// Sets the socket into non-blocking mode.
void
unblock_socket
(
fd_t
s_
);
...
...
src/ipc_listener.cpp
View file @
0bf1d026
...
...
@@ -103,7 +103,11 @@ void zmq::ipc_listener_t::in_event ()
int
zmq
::
ipc_listener_t
::
get_address
(
std
::
string
&
addr_
)
{
struct
sockaddr_storage
ss
;
#ifdef ZMQ_HAVE_HPUX
int
sl
=
sizeof
(
ss
);
#else
socklen_t
sl
=
sizeof
(
ss
);
#endif
int
rc
=
getsockname
(
s
,
(
sockaddr
*
)
&
ss
,
&
sl
);
if
(
rc
!=
0
)
{
addr_
.
clear
();
...
...
src/pgm_socket.cpp
View file @
0bf1d026
...
...
@@ -86,7 +86,6 @@ int zmq::pgm_socket_t::init_address (const char *network_,
pgm_error_t
*
pgm_error
=
NULL
;
struct
pgm_addrinfo_t
hints
,
*
res
=
NULL
;
sa_family_t
sa_family
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
AF_UNSPEC
;
...
...
src/stream_engine.cpp
View file @
0bf1d026
...
...
@@ -78,7 +78,7 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_) :
#endif
}
#if
defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_FREEBSD
#if
def SO_NOSIGPIPE
// Make sure that SIGPIPE signal is not generated when writing to a
// connection that was already closed by the peer.
int
set
=
1
;
...
...
src/tcp.cpp
0 → 100644
View file @
0bf1d026
/*
Copyright (c) 2010-2011 250bpm s.r.o.
Copyright (c) 2007-2009 iMatix Corporation
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ip.hpp"
#include "tcp.hpp"
#include "err.hpp"
#include "platform.hpp"
#if defined ZMQ_HAVE_WINDOWS
#include "windows.hpp"
#else
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif
#if defined ZMQ_HAVE_OPENVMS
#include <ioctl.h>
#endif
void
zmq
::
tune_tcp_socket
(
fd_t
s_
)
{
// Disable Nagle's algorithm. We are doing data batching on 0MQ level,
// so using Nagle wouldn't improve throughput in anyway, but it would
// hurt latency.
int
nodelay
=
1
;
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
nodelay
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
#ifdef ZMQ_HAVE_OPENVMS
// Disable delayed acknowledgements as they hurt latency is serious manner.
int
nodelack
=
1
;
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_NODELACK
,
(
char
*
)
&
nodelack
,
sizeof
(
int
));
errno_assert
(
rc
!=
SOCKET_ERROR
);
#endif
}
void
zmq
::
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
)
{
// Tuning TCP keep-alives if platform allows it
// All values = -1 means skip and leave it for OS
#ifdef ZMQ_HAVE_SO_KEEPALIVE
if
(
keepalive_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
char
*
)
&
keepalive_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
#ifdef ZMQ_HAVE_TCP_KEEPCNT
if
(
keepalive_cnt_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPCNT
,
&
keepalive_cnt_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPCNT
#ifdef ZMQ_HAVE_TCP_KEEPIDLE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPIDLE
,
&
keepalive_idle_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#else // ZMQ_HAVE_TCP_KEEPIDLE
#ifdef ZMQ_HAVE_TCP_KEEPALIVE
if
(
keepalive_idle_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPALIVE
,
&
keepalive_idle_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPALIVE
#endif // ZMQ_HAVE_TCP_KEEPIDLE
#ifdef ZMQ_HAVE_TCP_KEEPINTVL
if
(
keepalive_intvl_
!=
-
1
)
{
int
rc
=
setsockopt
(
s_
,
IPPROTO_TCP
,
TCP_KEEPINTVL
,
&
keepalive_intvl_
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#endif // ZMQ_HAVE_TCP_KEEPINTVL
}
#endif // ZMQ_HAVE_SO_KEEPALIVE
}
src/tcp.hpp
0 → 100644
View file @
0bf1d026
/*
Copyright (c) 2010-2011 250bpm s.r.o.
Copyright (c) 2007-2009 iMatix Corporation
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_TCP_HPP_INCLUDED__
#define __ZMQ_TCP_HPP_INCLUDED__
#include "fd.hpp"
namespace
zmq
{
// Tunes the supplied TCP socket for the best latency.
void
tune_tcp_socket
(
fd_t
s_
);
// Tunes TCP keep-alives
void
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
);
}
#endif
src/tcp_connecter.cpp
View file @
0bf1d026
...
...
@@ -29,6 +29,7 @@
#include "random.hpp"
#include "err.hpp"
#include "ip.hpp"
#include "tcp.hpp"
#include "address.hpp"
#include "tcp_address.hpp"
#include "session_base.hpp"
...
...
src/tcp_listener.cpp
View file @
0bf1d026
...
...
@@ -31,6 +31,7 @@
#include "config.hpp"
#include "err.hpp"
#include "ip.hpp"
#include "tcp.hpp"
#include "socket_base.hpp"
#ifdef ZMQ_HAVE_WINDOWS
...
...
@@ -133,7 +134,11 @@ int zmq::tcp_listener_t::get_address (std::string &addr_)
{
// Get the details of the TCP socket
struct
sockaddr_storage
ss
;
#ifdef ZMQ_HAVE_HPUX
int
sl
=
sizeof
(
ss
);
#else
socklen_t
sl
=
sizeof
(
ss
);
#endif
int
rc
=
getsockname
(
s
,
(
struct
sockaddr
*
)
&
ss
,
&
sl
);
if
(
rc
!=
0
)
{
...
...
@@ -233,7 +238,11 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
zmq_assert
(
s
!=
retired_fd
);
struct
sockaddr_storage
ss
=
{
0
};
#ifdef ZMQ_HAVE_HPUX
int
ss_len
=
sizeof
(
ss
);
#else
socklen_t
ss_len
=
sizeof
(
ss
);
#endif
fd_t
sock
=
::
accept
(
s
,
(
struct
sockaddr
*
)
&
ss
,
&
ss_len
);
#ifdef ZMQ_HAVE_WINDOWS
...
...
tests/test_connect_resolve.cpp
View file @
0bf1d026
...
...
@@ -40,7 +40,7 @@ int main (int argc, char *argv [])
int
rc
=
zmq_connect
(
sock
,
"tcp://localhost:1234"
);
assert
(
rc
==
0
);
rc
=
zmq_connect
(
sock
,
"tcp://
foobar123xyz
:1234"
);
rc
=
zmq_connect
(
sock
,
"tcp://
0mq.is.teh.best
:1234"
);
assert
(
rc
==
-
1
);
assert
(
errno
==
EINVAL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment