take a look at Martin's tcpmux implementation. From your problem description, it sounds like tcpmux is the way to go. https://github.com/nanomsg/nanomsg/blob/master/src/devices/tcpmuxd.c On Tue, Jan 13, 2015 at 10:51 AM, Lyle Thompson <lthompson@xxxxxxxxxxx> wrote: > I am looking to reimplement a message broker that I wrote in 0mq with > nanomsg. I was using ROUTER extensively in that implementation, which of > course nanomsg doesn’t have. So I’m just looking for some implementation > advice. So it all starts with the receiving socket, which needs to accept > connections from multiple sources, associate the connection “name” with > that socket and prepend it to the message as the first “frame”, and then > pass the message on up. Later, when sending a message, I will pop the first > “frame”, look up the associated socket, and send it down. > > > > So the first problem I’m seeing is just having a socket that serves > multiple clients, and can identify them uniquely. So without the equivalent > of a select or accept call, what is the best way to build a server? I’m > thinking of build a pool of nn_pair sockets, bind them one at a time. But I > see lots of potential problems here (Can multiple sockets bind to the same > port? does a bound socket stop listening on the port? Etc.). But I don’t > see any functionality to automatically create an ephemeral socket on an > incoming connection. > > > > My goal is to have a single port open on the broker (maybe two including > pub/sub). > > > > Any suggestions would be most helpful. > > > > Thanks! > > Lyle > -- Best regards, Jason -- Jason E. Aten, Ph.D. j.e.aten@xxxxxxxxx 650-429-8602 linkedin: https://www.linkedin.com/pub/jason-e-aten-ph-d/18/313/45a