zeromq/libzmq — pull request #238 by ianbarber (2012-02-08 22:12:18+00:00)
Title: Wildcard support in TCP and IPC addresses

Please don't merge this yet - it's just to have an easy reference for comment on the list, as there may well be unstable stuff in here!

The idea is to allow setting a wildcard in those transport uris, and retrieving the bound addresses. Currently it is only triggered by doing bind() on IPC and TCP connections (though inproc would be easy enough, and probably PGM too, and adding connect is no harder, though slightly odd).

Usage is pretty simple:

#include "zmq.h"
#include

int main (void)
{
size_t len = 255;
char endpoint[len];
void *context = zmq_init(1);

void *sock = zmq_socket(context, ZMQ_REQ);
// Test 1: test with specified host portion
zmq_bind(sock, "tcp://127.0.0.1:*");
zmq_getsockopt(sock, ZMQ_LAST_ENDPOINT, &endpoint, &len);
printf("%d - %s\n", (int)len, endpoint);

// Test 2: Test with IPC
len = 255; // reset the length
zmq_bind(sock, "ipc://*");
zmq_getsockopt(sock, ZMQ_LAST_ENDPOINT, &endpoint, &len);
printf("%d - %s\n", (int)len, endpoint);

zmq_close(sock);
zmq_term(context);
return 0;
}