Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wondered if it is possible to bridge two incoming tcp sockets.
For example:

Client A  ----->  Server  <----- Client B

The the server sends it's magic to both clients and then they connect to each other bypassing the server

                  Server
Client A  ----------><---------- Client B

UPDATE:

The idea is when those clients can't bind to ports to listen to still be able to create connection between each other with the help of the server.

For example Client A and Client B have tcp sockets with the server. User A decides to chat with User B and creates a new tcp connection with the server with the request to bridge it with User B. The server sends that request to Client B and it also opens up a new tcp connection with the server for that chat line.

Now when the server has both chat connections from A and B it bridges them and they can work without the server, and as a result the server won't have to process all the messages and files the two users share. That's the idea/

share|improve this question
    
This question is way too vague to answer. But the short answer is that it's possible under some circumstances and not under others. –  David Schwartz Sep 18 '12 at 18:04
    
@Itehnological It would help if you added example applications on the Client A and B. –  bbaja42 Sep 19 '12 at 6:44
    
@bbaja42 I am trying to achieve such behavior in one of my applications. –  Itay Grudev Sep 19 '12 at 8:25
    
AS David already mentioned, there isn't enough info to give a good answer. Which party should create the bridge on the server, client A or B, or the server. Does Client A or B start the connection? It is possible ssh port forwarding could work, but at this point it is unknown. –  bbaja42 Sep 19 '12 at 8:30
    
I updated the question with an example –  Itay Grudev Sep 19 '12 at 8:48

1 Answer 1

up vote 1 down vote accepted
+50

It is unclear whether both the clients are on the same network. I assume that they are not, otherwise this question wouldn't have come up.

From the above assumption it follows that one client cannot directly address a TCP/IP packet to the other client, so this absolutely requires a bridge. So in a general manner, the answer is that this is impossible - a bridge will always be required as an intermediary.

However, if the two clients are both connected to the Internet through a router, they can use the Internet as a bridge, for example by using the pwnat software. For more details see this answer of mine.

share|improve this answer
    
Well my assumption is also that in most cases the clients won't be able to bind a port to a static ip address and I was searching for alternative methods for enabling that communication without the need of a server to forward each message. –  Itay Grudev Sep 21 '12 at 19:33
    
pwnat may be exactly what you are looking for, if it works in your case. –  harrymc Sep 21 '12 at 19:42
    
I believe this is a solution. Thanks - +50 –  Itay Grudev Sep 22 '12 at 6:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.