简体   繁体   中英

Binding a socket connection to different port on different machine?

I have proxy server (on windows machine) that accepts client requests (using java sockets) and I have several internal nodes(unix machines) for processing these requests (in local area network). How to bind the incoming socket connection to a different machine on different port ?

for example I have an incoming connection from client (xxx.xxx.xxx.xxx:5000) to my proxy server (yyy.yyy.yyy.yyy:6000) and I want to bind this TCP Connection to a node on (zzz.zzz.zzz.zzz:7000).

Please let me know different possible ways in achieving this scenario ? Thanks in Advance !

You cannot bind a connection to another machine. A proxy is supposed to:

  1. accept an inbound connection from a client
  2. create its own client connection to the next server (typically the client would specify this, unless you handle this in your proxy's configuration)
  3. pass data back and forth between the two connections as needed

So, a client would connect to your proxy at yyy.yyy.yyy.yyy:6000, then your proxy would connect to zzz.zzz.zzz.zzz:7000 and start monitoring both connections for inbound data. Any data received on either connection would need to be sent to the other connection. Repeat until one of the connections is closed, then close the other connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM