Eduardo Pinheiro
Eduardo Pinheiro

Reputation: 3789

Changing 2 client sockets for a communication peer to peer without the server?

Is it possible this Scenario without using webrtc?

  1. Client A connects to Server
  2. Client B connects to Server
  3. Server send information to B and to A with each others information
  4. A and B start talking directly using the same connection (by transforming their sockets info with the new port/ip address for example)

note: Client A and B doesn't have any socket server. They are only clients

Thank you very much.

Upvotes: 0

Views: 72

Answers (1)

Jeremy Friesner
Jeremy Friesner

Reputation: 73294

It's definitely possible to set up a direct TCP connection, if at least one of the clients can accept an incoming TCP connection. In that case the server can just tell the other client what IP address and port to connect to, and then the two clients can communicate directly over the new TCP connection.

If both clients are behind firewalls or NAT, on the other hand, things get a lot more iffy -- in some cases you can use TCP hole punching techniques to get a direct TCP connection started; in other cases you're just out of luck.

In no case (AFAIK) can you modify an existing TCP connection to have new endpoints; a TCP connection's endpoints are fixed, and to get new endpoints you have to set up a new TCP connection.

Upvotes: 1

Related Questions