Important: some basic systems & networking knowledge is required in this article.
You’ve certainly already faced this use case: you just want to share some file with a coworker, but emailing it to them seems so overkill and frustrating when they’re sitting right next to you. Cheer up, we’ve got just the right thing for you!
You can use a combination of ser2net and socat. For example, I have a robot connected to a raspberry pi through a serial port. The raspberry pi is connected to.
We’ll use the socat utility to achieve our goal. socat is a simple yet powerful tool that allows for setting up a bidirectional exchange channel between 2 endpoints. An «endpoint» can basically be anything: the result of reading a file, a TCP or UDP socket, and much more.
Installation and basic operation
First, you’ll need to install the socat package; on Debian/Ubuntu, type this command in your terminal:
The
socat
command’s usage is pretty straight-forward:(
address
parameters are the «endpoints» we talked about earlier.)Note: we said earlier that socat establishes a bidirectional communication by default, but for simplicity’s sake, we’ll use unidirectional communication only in the following examples, by systematically passing the
-u
option to the socat
command.So, for starters, let’s play with a very simple example. Type the following command in your terminal:
(This just prints The meaning of life is 42 in your terminal.)
In unidirectional mode, the leftmost address is the «source» (the reader), and the rightmost one is the «destination» (the writer). So, what we just ordered socat to do here is: read the result of executing
echo The meaning of life is 42
, and write it to STDOUT
. Pretty simple right?Sharing a file over the network
Now, back to our original subject. The conventional way to exchange content over a regular IP network is by opening a socket on both communication ends. Sockets are just «doors» that you open on 2 computers so they can communicate with each other over the network. A socket is bound to an IP address and a port number. For example, when you run the Apache HTTP server on your machine, you actually open a listening socket on port 80 (by default).
So what we’ll do is that we’ll just write the content of our .vimrc file to a listening TCP socket, so that our coworker can connect to our machine and read it. To achieve that, type the following command in your terminal:
(
reuseaddr
is just a handy option that allows for reusing a port number that was already used by socat before but is not fully closed yet.)We now have a listening TCP socket on port 5778, which will basically echo the content of our .vimrc file to whoever connects to it first.
Now, the coworker you want to share this file with will need to know your IP address to connect to the opened socket. There are multiple ways to acquire this piece of information, we’re not going to list them all, but one of them is typing this command in your terminal:
The output will more or less look like this:
This is a list of all your machine’s available network interfaces and their respective parameters, the IP address being one of them. The vast majority of small-size local networks use
192.168.0
or 192.168.1
as network prefix, so you’ll generally have to look for a line starting with inet 192.168.
; in this example, my IP address is 192.168.1.97
.So now, just ask your coworker to type the following command in their terminal (just replace the example IP address with your own, and choose a real path for the downloaded file):
Which would be equivalent to saying: read the content output by the TCP socket opened at
192.168.1.97:5778
, write it to STDOUT
, and pipe the result to a file.Voila, you just shared a file over the local network with only a few terminal commands!
Bonus
One last handy little trick: if the file you want to share is pretty big, it would be cool to have some kind of feedback concerning the download progress. You can use the pv utility to achieve that. On Debian/Ubuntu, install it by typing the following command in the terminal:
Then, just pipe the fetched stream into pv before redirecting to a file:
(The
-r
option will display the current download bitrate in real time.)There you go!
This article is from our internal knowledge base, we wanted to share it with you. ❤ Send us a KUDO-Tweet if this article has helped you !
The following are installation help pages as well as drivers for USB to Serial adapters. These range from the Minicom adapter as well as the Prolific adapter drivers as well as Windows and Linux instructions. Aten as well as Bafo make these adapters and you can check to see how best to use these and how to install them as well.
USB to Serial
You will note the number of USB to Serial adapter and rivers there are on this website.
VN:F [1.9.22_1171]
VN:F [1.9.22_1171]
USB to Serial Drivers, 10.0 out of 10 based on 1 rating Related Posts
- Prolific USB to Serial Driver (1.000)
- Gigaware USB to Serial Driver (1.000)
- Aten USB to Serial Driver (1.000)
- Bafo USB to Serial Driver (1.000)
- Prolific USB to Serial Comm Port Driver (1.000)