The tool should connect to any two TCP/IP servers and transparently route sends and receives between them. The tool should connect to both the TCP/IP servers and transparently forward any data it receives between the two.

The problem that the tool is intended to solve is that there are two networked devices, each behaving as a server. One of the devices will send TCP/IP data to its client when an event occurs on it, then other expects this data to be sent to it.

  • In what context? Depending on what program you are talking about, it could range any ware from "Impossible" to "Check 'client' under 'options'" – Grant Sep 14 '09 at 13:47
  • More info needed. What are you trying to accomplish? – Mark Sep 14 '09 at 13:56
  • Added some more description now. – Thomas Bratt Sep 14 '09 at 14:30
  • Usually, you need to connect two networked devices together by having one connect to the other. So the sender would open up a TCP/IP connection to the listener. Or the listener would open up a TCP/IP connection to the sender. – J. Polfer Sep 14 '09 at 15:57
  • 1
    @sheepsimulator: this is true, but in this case I have two TCP/IP servers, both with a listening socket. Hence the problem! :) – Thomas Bratt Sep 14 '09 at 16:02

NOTE: Answer is completely revised based upon clarifications.

OP has two servers, both listening. One sends out data, the other is waiting for it to come in. But they are both listeners, and require a TCP/IP client to connect to both of them at the same time.

You need, essentially, a pipe program, that connects to both of the servers at the same time, and whatever is sent out of one server should be sent to the other.

Checkout the netcat program (Windows version available here). You might be able to do something like this:

nc <send svr> <send svr port> | nc <recv svr> <recv svr port>
| improve this answer | |
  • Thanks for the tip and the link :) I really have two TCP/IP servers, each using a listening socket and waiting for an incoming connection. There is no 'sending server' (ie a client) in this setup. – Thomas Bratt Sep 14 '09 at 16:00
  • Excellent! I'll check it out :) – Thomas Bratt Sep 14 '09 at 16:37
  • @sheepsimulator, your mental powers are strong. I would have never guessed the meaning of this question :) – vava Sep 14 '09 at 22:06
  • 1
    It works, thank you :) Just to let you know - it will be used for a trade show in Stockholm next week, where it will forward motion-detection events to a server I wrote. Eventually we will write some software to connect as a client but we don't have time before the show. – Thomas Bratt Sep 15 '09 at 8:52
  • @vava - It was an iterative process. Check out my edit log, this answer has gone through 7 revisions. – J. Polfer Sep 15 '09 at 13:09

Servers running TCP/IP can already communicate freely, assuming they're on the same net. That's what TCP/IP does. You might need to hook up a router of some sort if they're on different nets. If that's your issue, you need to describe your problem more fully, because what might be good for connecting isolated nets might not be good for subnets using NAT with a single IP address.

By mentioning "server" and "client", you seem to be implying some sort of application that communicates with TCP. However, many programs have distinct client and server roles that are not interchangeable. A Subversion server will not check out a source tree, for example. There is no automatic translation, and can't be, since people keep writing new programs. If you have a specific application, or list, in mind, you could add that to your question.

| improve this answer | |
  • The problem is that I have two devices, each of which behaves like a TCP/IP server. One of them will generate some data when an event occurs and I would like to have this data automatically forwarded to the other server. – Thomas Bratt Sep 14 '09 at 15:30

Based on the revised text, "You need, essentially, a pipe program, that connects to both of the servers at the same time, and whatever is sent out of one socket should be put into the other.", this sounds to me like a load balancer. And for this, you might actually look at load balancing / failover hardware. And this kind of connection is best managed by hard-ware based devices.

| improve this answer | |
  • Can you find a practical example where that is/can be used in that way? Sounds like overkill. – J. Polfer Sep 14 '09 at 16:45
  • It all depends on how fast is your connection, and how critical it is. Cisco makes some of this hardware. However, you should be able to have a software-based solution, using Linux and a PC with three or more NICS to provide load balancing. For example, if you have a web site that you need to have load balancing/fail over, you can have the two web sites behind the load balancer, with some synchronizing tool for the content, and the load balancer in front of them, showing a single IP address. Where it becomes trickier, is managing connection-less sessions. – jfmessier Sep 15 '09 at 11:54

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