Let\'s say Java has two kind of sockets:
Imagine the situation of two
First of all, don't call an accepted client (server-side) its socket a Client Socket
. That is very confusing.
Let's say how to have two client socket get interconnected without using an intermediate ServerSocket?
That is impossible. You always have to make a server-side, which can accept clients. Now the question is: which side of the connection should be the server-side?
Things you have to think about by this decision:
Middle server
Why don't make immediately a connection to the VNCServer?
But if you really want it, you can make a situation like this:
/ VNCServer (Server Running) <---. | | LAN -| Connects to VNCServer | | \ MyApp (Server Running --> Accepts from Middle Server) <------. | (Through a router) | Middle server (Server Running --> Accepts client) ---> Connects to Your App ^ | (Through a router) | Client --> Connects to Middle Server --°
And this is how it looks without the third server (What I recommend you):
/ VNCServer (Server Running) <---. | | LAN -| Connects to VNCServer | | \ MyApp (Server Running --> Accepts Clients) <------. | (Through a router) | Client --> Connects to MyApp --------------------------°
EDIT:
I think I got it now:
We have to visualize your situation like this:
Your Main Server (What you called middle server) (1) | | (2) /⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻/ \⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻\ | | Your VNCServer <----------------------------> The client (5) (3)
(1)
The VNCServer connects to the main server. So, then the main server got the VNCServer its IP.
(2)
The client connects to the main server.
(3)
Now the main server knows where server and client are. Then he sends to the client where the server is. Then the client will connect to the IP he received from the main server. That is of course the IP from the VNCServer.
(5)
The VNCServer is running is server to accept the client.
Now desktop sharing can start.
I think this is the most recommend situation you can have.
Of course writing it in Java is to you.