Paul Mark
Paul Mark

Reputation: 199

TCP socket proxy forwarder

My question is more general rather than specific. I want to implement a simple socket proxy server, where the server will receive requests from multiple clients, and forward it to another server using a single and unique connection, and the way back, the response comes to client.

The question is, can I keep a TCP connection open (maybe using ping?) and traffic the data inside it, so the final server will only count one connection? Like the example below.

client 1 - - -|        |  Single Con |
client 2 - - -| Proxy  |  -------->  |Destination
client 3 - - -| Server |  <--------  |Server
client 4 - - -|        |             |

Any suggestion or example?

Upvotes: 0

Views: 514

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123441

If multiple client connections can be shared within the same TCP connection fully depends on the application protocol. There is nothing in TCP itself which prevents it but there is nothing in TCP which explicitly supports it either. One would need to be implement the distinction between the different client streams (i.e. originally client connections) through some multiplexing at the application layer and the destination server must support this, i.e. must be able to demultiplex it again.

Upvotes: 1

Related Questions