Skip to content

Commit

Permalink
Merge pull request zeromq#2639 from bluca/wine_doc
Browse files Browse the repository at this point in the history
Problems: using Wine requires system tuning, ZMQ_BINDTODEVICE not draft
  • Loading branch information
jimklimov authored Aug 1, 2017
2 parents a34adbf + bb0b518 commit fda9daa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
11 changes: 11 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ can cause substantial consumption of virtual address space, especially if
Generally, programmer needs to tune the stack to balance memory consumption
but never get into situation that stack is overflown.

Windows Builds - Wine
=====================

To use Windows binaries on *nix via Wine, it is necessary to ensure that the
kernel TCP buffers are large enough. On some systems, like OS X, they are too
small by default.
They need to be set to at least one MB as a workaround for issue:
https://github.com/zeromq/libzmq/issues/1608

sudo sysctl -w net.inet.tcp.sendspace=1300000

Basic Installation
==================

Expand Down
4 changes: 3 additions & 1 deletion include/zmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg, const char *property)
#define ZMQ_VMCI_BUFFER_MAX_SIZE 87
#define ZMQ_VMCI_CONNECT_TIMEOUT 88
#define ZMQ_USE_FD 89
#define ZMQ_BINDTODEVICE 90

/* Message options */
#define ZMQ_MORE 1
Expand Down Expand Up @@ -562,6 +561,9 @@ ZMQ_EXPORT void zmq_threadclose (void* thread);
#define ZMQ_SCATTER 17
#define ZMQ_DGRAM 18

/* DRAFT Socket options. */
#define ZMQ_BINDTODEVICE 90

/* DRAFT 0MQ socket events and monitoring */
#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800
#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000
Expand Down
8 changes: 4 additions & 4 deletions src/udp_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ void zmq::udp_engine_t::plug (io_thread_t* io_thread_, session_base_t *session_)
io_object_t::plug (io_thread_);
handle = add_fd (fd);

// Bind the socket to a device if applicable
if (!options.bound_device.empty ())
bind_to_device (fd, options.bound_device);

if (send_enabled) {
if (!options.raw_socket) {
out_address = address->resolved.udp_addr->dest_addr ();
Expand All @@ -123,10 +127,6 @@ void zmq::udp_engine_t::plug (io_thread_t* io_thread_, session_base_t *session_)
errno_assert (rc == 0);
#endif

// Bind the socket to a device if applicable
if (!options.bound_device.empty ())
bind_to_device (fd, options.bound_device);

rc = bind (fd, address->resolved.udp_addr->bind_addr (),
address->resolved.udp_addr->bind_addrlen ());
#ifdef ZMQ_HAVE_WINDOWS
Expand Down
3 changes: 3 additions & 0 deletions src/zmq_draft.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#define ZMQ_SCATTER 17
#define ZMQ_DGRAM 18

/* DRAFT Socket options. */
#define ZMQ_BINDTODEVICE 90

/* DRAFT 0MQ socket events and monitoring */
#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800
#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000
Expand Down
4 changes: 3 additions & 1 deletion tests/test_setsockopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ void test_setsockopt_use_fd ()
#define BOUNDDEVBUFSZ 16
void test_setsockopt_bindtodevice ()
{
int rc;
void *ctx = zmq_ctx_new ();
void *socket = zmq_socket (ctx, ZMQ_PUSH);

#ifdef ZMQ_BINDTODEVICE
int rc;
char devname[BOUNDDEVBUFSZ];
size_t buflen = BOUNDDEVBUFSZ;

Expand All @@ -137,6 +138,7 @@ void test_setsockopt_bindtodevice ()
rc = zmq_getsockopt (socket, ZMQ_BINDTODEVICE, devname, &buflen);
assert(rc == 0);
assert(!strncmp("testdev", devname, buflen));
#endif

zmq_close (socket);
zmq_ctx_term (ctx);
Expand Down

0 comments on commit fda9daa

Please sign in to comment.