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
58b10824
Commit
58b10824
authored
Jun 30, 2013
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #600 from hurtonm/master
Set socket buffers before establishing TCP connection
parents
11947b1c
afe9afa2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
19 deletions
+40
-19
stream_engine.cpp
src/stream_engine.cpp
+0
-19
tcp.cpp
src/tcp.cpp
+22
-0
tcp.hpp
src/tcp.hpp
+6
-0
tcp_connecter.cpp
src/tcp_connecter.cpp
+6
-0
tcp_listener.cpp
src/tcp_listener.cpp
+6
-0
No files found.
src/stream_engine.cpp
View file @
58b10824
...
...
@@ -83,25 +83,6 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_,
// Put the socket into non-blocking mode.
unblock_socket
(
s
);
// Set the socket buffer limits for the underlying socket.
if
(
options
.
sndbuf
)
{
rc
=
setsockopt
(
s
,
SOL_SOCKET
,
SO_SNDBUF
,
(
char
*
)
&
options
.
sndbuf
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
if
(
options
.
rcvbuf
)
{
rc
=
setsockopt
(
s
,
SOL_SOCKET
,
SO_RCVBUF
,
(
char
*
)
&
options
.
rcvbuf
,
sizeof
(
int
));
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
#ifdef SO_NOSIGPIPE
// Make sure that SIGPIPE signal is not generated when writing to a
...
...
src/tcp.cpp
View file @
58b10824
...
...
@@ -59,6 +59,28 @@ void zmq::tune_tcp_socket (fd_t s_)
#endif
}
void
zmq
::
set_tcp_send_buffer
(
fd_t
sockfd_
,
int
bufsize_
)
{
const
int
rc
=
setsockopt
(
sockfd_
,
SOL_SOCKET
,
SO_SNDBUF
,
(
char
*
)
&
bufsize_
,
sizeof
bufsize_
);
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
void
zmq
::
set_tcp_receive_buffer
(
fd_t
sockfd_
,
int
bufsize_
)
{
const
int
rc
=
setsockopt
(
sockfd_
,
SOL_SOCKET
,
SO_RCVBUF
,
(
char
*
)
&
bufsize_
,
sizeof
bufsize_
);
#ifdef ZMQ_HAVE_WINDOWS
wsa_assert
(
rc
!=
SOCKET_ERROR
);
#else
errno_assert
(
rc
==
0
);
#endif
}
void
zmq
::
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
)
{
// These options are used only under certain #ifdefs below.
...
...
src/tcp.hpp
View file @
58b10824
...
...
@@ -28,6 +28,12 @@ namespace zmq
// Tunes the supplied TCP socket for the best latency.
void
tune_tcp_socket
(
fd_t
s_
);
// Sets the socket send buffer size.
void
set_tcp_send_buffer
(
fd_t
sockfd_
,
int
bufsize_
);
// Sets the socket receive buffer size.
void
set_tcp_receive_buffer
(
fd_t
sockfd_
,
int
bufsize_
);
// Tunes TCP keep-alives
void
tune_tcp_keepalives
(
fd_t
s_
,
int
keepalive_
,
int
keepalive_cnt_
,
int
keepalive_idle_
,
int
keepalive_intvl_
);
...
...
src/tcp_connecter.cpp
View file @
58b10824
...
...
@@ -226,6 +226,12 @@ int zmq::tcp_connecter_t::open ()
// Set the socket to non-blocking mode so that we get async connect().
unblock_socket
(
s
);
// Set the socket buffer limits for the underlying socket.
if
(
options
.
sndbuf
!=
0
)
set_tcp_send_buffer
(
s
,
options
.
sndbuf
);
if
(
options
.
rcvbuf
!=
0
)
set_tcp_receive_buffer
(
s
,
options
.
rcvbuf
);
// Connect to the remote peer.
int
rc
=
::
connect
(
s
,
addr
->
resolved
.
tcp_addr
->
addr
(),
...
...
src/tcp_listener.cpp
View file @
58b10824
...
...
@@ -188,6 +188,12 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
if
(
address
.
family
()
==
AF_INET6
)
enable_ipv4_mapping
(
s
);
// Set the socket buffer limits for the underlying socket.
if
(
options
.
sndbuf
!=
0
)
set_tcp_send_buffer
(
s
,
options
.
sndbuf
);
if
(
options
.
rcvbuf
!=
0
)
set_tcp_receive_buffer
(
s
,
options
.
rcvbuf
);
// Allow reusing of the address.
int
flag
=
1
;
#ifdef ZMQ_HAVE_WINDOWS
...
...
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