HOW-TO: Copy files from network
then!
often happens that we need to send information from one PC to another, but for reasons they are, the solutions "conventional" we do not solve the problem. Suppose we want to send the entire contents of a hard drive or just want to send "information release" for communication between programs, but do not want to be reading files in shared folders, or want to make a communication program ...
Well, we can use sockets to send this information. In Linux, we have the tool "nc" (there is plenty of information on the Internet) is nc tool that will allow us to create sockets for everything that comes to mind.
Let's review the concept of socket. Socket is a communication method by which two entities communicate, which can acquire the role of client or server.
Make a socket is very easy, in a "customer" write ip 192.168.1.10:
nc-l-p 6000
In a "server" write: nc 192.168.1.10 6000
Observe that everything you write on the server appears in the client console. In this case, client and server can be two consoles on the same computer. Press Ctrl + c to end the session. Look
"man nc" to see what each parameter. Now let's send a file:
PC (or console) Receiver: nc-l 6000 6000
Observe that although the file was received, the connection does not close until you hit control + c in the issuer (if we do it in the receiver may not receive all the information) that also sets the transmission is closed if the client hit control + c, we must remember those things.
Now suppose we have a large file and we are so clever they decided to send it compressed, but it is so great that can not be compressed without filling up the remainder of the disc. Well, we can compress the fly
192.168.1.10 PC Receiver: nc-l 6000 compress the file but not store it in local disk, but it sends it to standard output (Parameter "f -") There is addressed to and sent to 192.168.1.10 nc
Meanwhile, the receiver directs all that reaches across the network to the standard output and there is directed to tar to be unpacked in the same place.
benefits are obviously the better use of bandwidth and that the information is compressed.
observed that the transmission does not close until the issuer press control + c on your console.
power Imagine this: you can do, communication scripts, backups on the fly communication protocols and everything you can think of. Let
partridge rolling over and giving another turn of thread. Let's make a program of communication theory.
PC 1: 192.168.1.10
In a console 1:
nc-l-u-p 6000
In another console 2: nc-u
192.168.1.11-p 7000
PC 2: 192.168.1.11
In a console 1:
nc-l-u-p 7000
In another console 2: nc-u
6000 192.168.1.10
There it is: everything write to the console 2 will be sent to the console 1 from the other team, and all that another computer on your console type 2 will be sent to the console 1 from ours.
Observe the "-u". This means that using the protocol "UDP" (send unacknowledged) ie if the other press control + c on your console, do not break our console, in fact, do not know if it's there.
Henceforth, all yours, all you can think of.
Linux power!
0 comments:
Post a Comment