sockets - Client-Server Discovery Service on localhost -


i have application want extend publishing data out socket when key events happen custom application wants listen packets can process them.

my inclination send packets on udp on localhost server known clients involve clients sending messages known server address such 127.0.0.1:12345, subscribing using own address 127.0.0.1:54321, , server sends out copy of packet each active subscriber every time event happens.

i see few problems need solving here:

  1. servers possibly in contention , try bind same "known" server port @ 127.0.0.1:12345

  2. clients need made aware of every available server publishing messages user can select server interested in listening to

  3. server need periodically ask each client if still listening since udp

there has better way! there way can write network communications in manner allows clients share same port(then there wouldn't need client-server handshake)? if wanted extend across lan, how can publish information machines interested(inclination multicast cleanest approach, how can make multicast work when or clients exist on localhost)?

every solution has pros , cons there no better way it. in end might gain using specific library inter-application messaging zeromq or rabbitmq instead trying reinvent wheel writing own code implement subscriber/publisher , multicasting patterns

edit: answer questions in case decide reinvent wheel:

1) there no other way having single server per unique {protocol, ip, port} tuple. either allow 1 server wear several hats or have 1 port per server.

2) need server registry work. alternative can broadcast message user sends requesting servers identify themselves.

3) yes - need keepalive know if user still there. alternatively, user can periodically contact server still here.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -