Socket left in TIME_WAIT after file transfer via netcat

Posted by com on Stack Overflow See other posts from Stack Overflow or by com
Published on 2012-04-15T14:51:35Z Indexed on 2012/04/15 17:29 UTC
Read the original article Hit count: 193

Filed under:
|

Using Copying by NetCat I am trying to copy files throught network by NetCat. From console it work pretty well. First I run listening netcat on the destination machine and after I run sending on source machine.

The problem is it's doen't work from script from the source machine:

ssh -f user@$desthost 'nc -l 1234 | tar xvf - > /dev/null &' #listening on destination host

tar cv /tmp/file | nc $desthost 1234 #sending to destination host

I saw that after running port 1234 is still was open and status of the socket was TIME_WAIT.

If you know what's the problem, please, help me out.

And by the way, after copying how can I validate that the content is identical?

Thanks!

Addendum:

I found one very strange thing, the same implementation with screen on destination work works, but not stable, sometimes it doesn't copy a file.

ssh user@$desthost screen -dm -S test 'nc -l 1234 | tar xvf - ' #listening on destination host

Maybe there is an issue with timeout?

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash