Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

While experiencing an extremely slow download rate on one of my HTTP connections, I thought it'd be nice if I could just transfer the connection from my PC to an energy-saving home server that shares the same external IP address.

The way I imagine it, I'd like to run a command that would take over the connection from a specific IP and a port, letting me pipe all incoming data that flows through it to a file without letting the original owner of the connection to close it.

Are there already any tools for that?

share|improve this question

3 Answers 3

That doesn't make sense in most cases. Abort the download, copy what's already downloaded to the server and use wget to resume the download.

share|improve this answer
    
That's not really a solution when you're using free services like Rapidshare - you won't be able to resume the download then. –  d33tah May 31 '13 at 10:49
    
@d33tah I wrote "most" intentionally. :-) –  Hauke Laging May 31 '13 at 11:08

I don't think this is possible given the underpinnings of how a TCP/IP connection works in addition to the NAT firewall providing you the ability to share your external IP address among multiple computers on your LAN. That being said there are some tips/tricks which might help, one you understand how they work.

Tip #1 - screen/tmux

Typically what I do is if I have a large file to download, I'll ssh into another computer on my network, and run screen/tmux there. With a screen/tmux session I can run long running programs (such as a download) in a terminal without having them stop when I disconnect the ssh connection to this secondary machine.

The pattern looks like this:

laptop$ ssh remotemachine

...login...

remote$ screen -S mydownload

...now have a screen session called "mydownload"...

remote$ wget http://www.bigfiles.com/somebigfile

...Ctrl+A Ctrl+D.... <--- (disconnect from screensession)

...a little while later...

laptop$ ssh remotemachine
remote$ screen -r mydownload

...wget is still running in here...

Tip #2 - xdg-open

This program allows you to run files and/or URL's through the preferred application. For example, I've setup Firefox on a remote machine on my LAN so that it has an association for the 'magnet://' handler. With this on the remote machine, I can run commands like this:

ssh remotemachine "DISPLAY=:0.0; xdg-open magnet://url_of_magnet_link...."

On my laptop, and it will "trigger" my remotemachine to start downloading that magnet link through Firefox, which will then pass that URL on to the application that's associated with handling magnet:// links. In this case I'm using Vuze to do the handling.

If you're curious how to setup Firefox to do this I wrote about it on my blog a while back. The articles titled: [one-liner]: Howto get Firefox 10.x to Launch a BitTorrent Client via a Magnet Link on Linux.

share|improve this answer

From an IP, TCP and NAT perspective, this is definitely possible. I can imagine the server take on the PCs IP address. I can also imaging the server's Linux kernel prepare a connection transfer by initializing the required socket data structures and protocol control block. The actual connection transfer would require some coordination between the two Linux kernels.

And indeed one promising approach exists: TCP Connection Passing. It consists of a kernel patch which extends the socket API for connection passing and a set of tools to initiate the passing. This approach takes the role of the application layer into account.

The thing is: a TCP connection also involves an application state shared between the two ends. Both ends expect each other act according to that state. So if you replace one end by some generic entity which just sucks up data, not replying anything, you risk breaking the state (and thus the connection) just by not behaving properly. This might not be an issue for the scenario you've described, but it limits the applicability of the generic connection passing scheme you have in mind. So no, I don't think quite such a thing exists but TCP Connection Passing is a good start. You can tailor it to your needs.

share|improve this answer

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.