Pnelson
Pnelson

Reputation: 57

Nectcat end connection

Im using netcat to send files to another pc, using a client and a server. the problem is when i send a file from server to client, the content of the file is send, but the program doesnt continue in both computers.

Code from server:

($nc -nlv $server < xa.txt) 

Code from client:

($nc $ip_server $door > xa1.txt)
echo "done"

In this case doesnt show the echo, and recieves the file in the console, made the connections and the square is full colour.

Upvotes: 0

Views: 151

Answers (2)

Anonymous Coward
Anonymous Coward

Reputation: 11

use timeout options, such as

-q seconds   after EOF is detected, wait the specified number of seconds and then quit.

or

-w secs      timeout for connects and final net reads

Well, I think that you won`t be needing -w.

However, ncat(insecure.org, these guys who created nmap) disconnects as soon as it sees EOF.

Upvotes: 1

Edouard Thiel
Edouard Thiel

Reputation: 6228

That's normal: netcat reads until end of input on one side, and writes until end of connection. It is designed like this.

If you want to transfer several file, use a protocol intended for this: sftp, scp, rsync.

Another way is to use tar and netcat. On the receiving end do:

$ nc -lv $port | tar xvfz -

and on the sending end do:

$ tar cfz - * | nc $host $port 

Upvotes: 0

Related Questions