Adding ZMQ_LAST_ENDPOINT for wildcard support on TCP and IPC sockets

This commit is contained in:
Ian Barber
2012-02-08 22:06:46 +00:00
parent 7e8a839a22
commit 7b32c9cb51
9 changed files with 99 additions and 7 deletions

View File

@@ -95,8 +95,25 @@ void zmq::ipc_listener_t::in_event ()
send_attach (session, engine, false);
}
int zmq::ipc_listener_t::get_address (unsigned char *addr, size_t *len)
{
if (bound_addr_len == 0) {
return -1;
}
memcpy (addr, bound_addr, bound_addr_len + 1);
*len = bound_addr_len + 1;
return 0;
}
int zmq::ipc_listener_t::set_address (const char *addr_)
{
// Allow wildcard file
if(*addr_ == '*') {
addr_ = tempnam(NULL, NULL);
}
// Get rid of the file associated with the UNIX domain socket that
// may have been left behind by the previous run of the application.
::unlink (addr_);
@@ -125,6 +142,9 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
if (rc != 0)
return -1;
// Return the bound address
bound_addr_len = sprintf(bound_addr, "ipc://%s", addr_);
return 0;
}