Here is my problem:
I have one computer which is connected directly to the internet through a network card and modem. using a second network card i connect a hub and to that hub i connect several computers.
Now, when the computers behind the hub use some network program the info goes out but when data to the port comes back in it cannot find the original computer since it is behind the computer connected to the internet (All computers share the same IP, of course).
Now what i want to do is rather simple. i want to write a program that "catches" incoming traffic through a specific port and redirects it to the same port on a different ip. This program should be put on the computer connected to the internet and theoretically should solve my problem.
I am not sure exactly, however, of how to go by it. If someone could explain to me the correct usage of sockets for this problem or at least link me to some useful source code that does something alike (and i'm pretty sure i'm not the first person with this problem, so there should be plenty out there) i'd be very thankful
tx in advance
06-14-2006, 03:53 AM
I think it would be safer and easier to buy a little router.
06-14-2006, 08:52 AM
I agree wholeheartedly, but my interest in this is academic
06-14-2006, 12:41 PM
Then you want to simulate a router, embedded in "master" pc ? Sounds like a pretty good idea though. Good luck !
06-16-2006, 07:36 AM
it's not that difficult to build a tcp-redirection within java.
what you have to do is a simple serversocket that accepts incoming connections.
the connection is represented by an inputstream.
on the other hand, the serversocket has to open a client connection to the target, represented by an outputstream. now the serversocket just has to write everything received from the inputstream to the outputstream.
that's all. i once write that, but don't have the code at hand.
06-16-2006, 10:17 AM
That's exactly what i tried to do but at some point i just keep getting null strings from the input and of course it doesn't help the output anything.
What i miss is the semantics, such as exactly how to build the input and output streams from the sockets. If any1 could tell me which streams are needed for the i/o i'll be very grateful.