Mohsen Shakiba
Mohsen Shakiba

Reputation: 1872

C# - Socket router for passing sockets to multiple socket servers

is it possible to have one socket router that would pass incoming sockets to socket servers?
I need this because I want to have multiple servers for handling sockets but only one port for clients to connect to. so if one of the servers goes down, router would send the socket to other healthy socket servers.
Is this even possible and how? or any other solution for my problem?

Upvotes: 0

Views: 706

Answers (1)

jython234
jython234

Reputation: 315

Yes this is definitely possible, and is used very widespread.

Basically you need to have one TCP server running on that one port you want clients to connect to. Then you can listen for connections. When a connection is established you can reroute packets to other servers (you choose).

  1. Listen on a port with your main server
  2. Accept connections as they come in.
  3. When a connection is opened, read the data in another thread. Take that data and send it to the other server you want to.

Basically, it is a proxy.

Upvotes: 2

Related Questions