Take the 2-minute tour ×

I have an application which communicates over the local area network. However, I want to instead make it communicate over the internet. To do this I propose making an intermediate program which will read the network traffic generated from the application on one computer and send it to the application on another computer.

This involves:

  1. Reading the outgoing network traffic of the application
  2. Sending a copy of this traffic over the internet to another computer
  3. Giving this copy to the application on the other computer

Instead of this:

Application on computer A <-LAN-> Application on computer B

I want to achieve this:

Application on A <--> My Program on A <-INTERNET-> My program on B <--> Application on B

I can accomplish (2), but with (1) and (3) my problem is that I have very little experience with networking and I do not know where to start. I can program in python but would be willing to use c++ to accomplish this.

(Hamachi does not work for this application, I do not know why.)

In response to comments

I do not intend to manipulate any data unless it is necessary to make the connection work. I have no control over the application itself and it does not provide me with any methods to configure the connection with the exception of a port number.

TCP and UDP are both used on the port 6112. The IP addresses used are first for a generic broadcast used to discover other applications on the LAN (with UDP), then a TCP connection is established.

share|improve this question
if your intention is to just have the 1st app talk to the 2nd app directly without any manipulation of data, you should be able to set the connection to go directly to the 2nd app. Otherwise you're going to need to built a type of tcp "tunnel" to do what you want ... App A talks to App B which relays messages to App C... Maybe having a clearer explanation of what you're trying to do would help more. –  g19fanatic Sep 7 '11 at 17:29
Need more information about the application. What protocol does it communicate in? Can you specify the IP address and port that it is sending to / receiving from? –  Andrew Humphries Sep 7 '11 at 17:30
you could use nc or ssh or more specialized programs mentioned by @tMC. –  J.F. Sebastian Sep 7 '11 at 20:13
add comment

2 Answers

Why re-engineer the wheel? Why not just use OpenVPN, n2n or vtun etc etc.

share|improve this answer
add comment

The term you are missing in your original question is proxy. You specifically need a transparent forwarding proxy.

Here is a link to some source code in Python that will get you started with writing a proxy.

That said, if you search around you should be able to find a transparent forwarding proxy that you don't have to write yourself.

If you want to do this the most robust way, you can do it in hardware and setup a managed router/switch/firewall to route things to where ever you need without having to write anything.

share|improve this answer
The problem that I am encountering is that the socket/port is already is use by the program (twisted.internet.error.CannotListenError: Couldn't listen on any:6112: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted.). If I start the program first then my normal application presumably encounters the same error (ie. it doesn't work so I assume it is the same problem). Do you know how to use a port that is already in use in twisted? –  Darth Sep 8 '11 at 12:13
you can't use the same port with two applications –  Jarrod Roberson Sep 8 '11 at 22:02
The difficulty of implementing the hardware approach means it is not feasible for other people to do on their own computers. Unless I am misunderstanding, I don't think I can use a normal proxy because I cannot redirect network traffic from the application to the proxy. It has a fixed destination. With what you have said, I see no way for my approach to work either. –  Darth Sep 10 '11 at 11:13
add comment

Your Answer


