On 11/05/2016 11:02 PM, Era Scarecrow via Digitalmars-d-learn wrote:
So I've got a project where I want to create basically a
decentralized chat program where every program is a host and a client.
When you connect all connections can go through to route the chat to
everyone else.
So to make this work I've looked over the sockets package and I don't
quite follow how you'd make it so it works a lot like a web browser,
aka when you get a connection you redirect to a different port so you
have 1 listening port for new connections so it can act as a server.
What settings or configuration would I need to be able to do that?
That sounds more like a job for udp than tcp sockets. You'd need to
implement an ack/nak protocol because udp doesn't guarantee delivery,
but unless you want a central server I don't see how you could use tcp.
The central server wouldn't need to do much, and could delegate most of
the processing, but it wouldn't be decentralized. I was looking into
using tcp (actually zmq) for something similar awhile back and tcp just
didn't seem to support actually decentralized communication. Udp
did...which meant I couldn't use zmq. That was a real pity because zmq
is basically a very nice package, and easy to wrap.