DESCRIPTION
Do you have an application (such as scp or unison file synchronize) that
cannot recover from broken tcp connections, and you hate that?!! this tool is
for you!!
ImmortalSockets is a standalone application that creates a TCP tunnel
for unreliable TCP connections. It can also be used as a library to create a
TCP socket that does not die.
That is, according to
man
sockets, "
The communications protocols which implement a SOCK_STREAM
ensure that data is not lost or duplicated. If a piece of data for which the
peer protocol has buffer space cannot be successfully transmitted within a
reasonable length of time, then the connection is considered to be dead.".
Thus, it happens often that the connection dies (or the connection breaks) if
you have an unreliable Internet connection. This is a problem with software
(such as scp or unison file synchronizer) that it is not designed to reconnect
when the connection dies and resume its operation.
ImmortalSockets can help you in these cases where you need to prevent the
connection to die under an unreliable Internet connection (hence the name,
Immortal Sockets).
Suppose you need to copy a file using scp. You would do something like this:
Without ImmortalSockets:
computer1> scp myfile.zip
computer2:myfile.zip
This copies a file. However, if the connection between computer1 and computer2
is broken, the copy needs to be restarted from the beginning.
Using ImmortalSockets:
computer2T> java
-cp ImmortalSockets.jar org.ImmortalSockets.tunnel.TunnelServer 2000 computer2
22
computer1T> java
-cp ImmortalSockets.jar org.ImmortalSockets.tunnel.TunnelClient 2001 computer2T
2000
computer1> scp -P 2001 myfile.zip
computer1T:myfile.zip
This copies a file. If the connection between computer1T and computer2T is
broken, TunnelServer/TunnelClient will reconnect, and scp will keep copying as
if nothing happened.
Of course, you can avoid needing two extra computers (Computer1T and
Computer2T) by running TunnelClient in Computer1 and TunnelServer in
Computer2.
The tunnel works very much as "
ssh -f -N
-L 2222:computer2T:3333 computer2".
This specifies that port 2222 on the local (client) host is to be forwarded to
computer2:3333 via computer2T using ssh. This works by allocating a socket to
listen to port 2222 on the local side. Whenever a connection is made to this
port, the connection is forwarded over the secure channel, and a connection is
made to myremotemachine.com:3333 from myremotemachine.com.
The difference is that ImmortalSockets "transparently reconnects" whenever the
tunnel connection is broken. By "transparently reconnecting" we mean that when
the tunnel connection is broken, the connection of the local application to
localhost:2222 is not closed, nor is the connection from computer2T to
computer2:3333, and thus the application does not even notice that the tunnel
connection was broken.
Note: to run this software, you need to:
- install Java if you don't already have it
- download ImmortalSockets_0.2.zip, unzip it and get the ImmortalSockets.jar file.
Note: you don't need 4 computers to use this software.
For the sake of understanding, the example above shows 4 computers: Computer1, Computer1T, computer2T and computer2;
but Computer1 and Computer1T can be the same computer,
and Computer2 and Computer2T can be the same computer.
Note: you will get a log4j warning when running the software. You can ignore it.
otherwise, you can take the log4j.properties file from the
ImmortalSockets_0.2.zip, and run:
computer2T> java
-cp ImmortalSockets.jar -Dlog4j.configuration=file:log4j.properties org.ImmortalSockets.tunnel.TunnelServer 2000 computer2
22
Currently ImmortalSockets is implemented in Java. If you wish to contribute,
you can port it to other languages (C/C++, C#, VisualBasic, perl, python, PHP,
javascript...).