How to create a "unique" socket in zeromq? -


i'm experimenting simple actor model in haskell, each actor:

  • is haskell thread
  • has zeromq pull socket upon receives messages

some actors "well known", have indefinite lifetimes, , hence have socket bound known port. other actors short lived , transient, , hence need random free port assigned them.

i unaware of ability of zmq3 allow binding ephemeral port, described here: http://api.zeromq.org/3-2:zmq-tcp

hence, transient actors have code tries bind free port within given range. works intended, brings light zmq behavior causes me problems: if transient actor closes it's port , exits, , new transient actor starts, it's bind same port os old one. in circumstance outstanding or subsequent messages queued old actor received new one.

how can avoid this?

if bound transient actors sockets using wildcard system assigned ephemeral port, still potentially see problem?

how can generate new unique pull socket tcp transport guaranteed distinct others?

in general usage, use bind() stable, "well known" actors, , use connect() transient actors. seems little weird if need port number transient actors.

also, perhaps should add protocol transient actors going away let other side know, other side won't continue send them messages (which received new transient actor bound same port old one).

i think system-assigned ephemeral ports try not reuse ports immediately, solve of problems.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -