This article is written by a student who is doing JS or something instead of a memo. Don't expect the content.
A communication method performed by the server of the computer that provides the service and the client of the computer that receives the service. The network is connected to the client radially from the server. P2P communication is often contrasted with this, and in the P2P type, all computers have both a server and a client.
This time it will be done on Ubuntu, so I will start the virtual environment with iTerm2.
Where it started
Move to the directory where Ubuntu is installed. vagrant up is a command to start Ubuntu installed on a virtual PC, and vagrant ssh connects to SSH with the Vagrant virtual machine set.
Start tmux when the console starts.
tmux
Here is a summary of simple tmux commands.
command | meaning | Where to write |
---|---|---|
tmux | Start-up | console |
control+b→d | Leave the virtual terminal | Virtual terminal |
tumux a | Connect to a virtual terminal | console |
control+b→c | Window creation | Virtual terminal |
control+b → number | Move window to numbers | Virtual terminal |
control+b→p | Move to previous number | Virtual terminal |
control+b→n | Move to a later number | Virtual terminal |
control+b→x | close the window | Virtual terminal |
First, when you have two windows, write the following contents in one window.
; do (echo "Thank you!") | nc -l 8000 ; done
In order to perform a loop called while, the contents of the loop are described in while:; do and done. nc in while is called nc command, this time
nc -l Port number
It is set to listen mode with -l and is listening on the specified port number. In this case, when there is an access, echo is displayed as Thank you !.
Next, write the following on the other side.
telnet 127.0.0.1 8000
127.0.01 is the IP address that identifies you. In this case, telnet is used to access port 8000 of the IP address. Telnet is a command to access a remote computer and start a terminal session. It seems that alternative protocols such as ssh are often used for security reasons.
When I executed the above description, the contents of echo were displayed, so I was able to communicate between the server and client !!
Let's chat using Transfer nc command file (FTP).
Server side
nc -l -p Port number File name
Connection side
I will describe the above.
This time on the server side
nc -l -p 8000
On the connection side
nc 127.0.01 8000
Was described.
It is successful if you write sentences on the console and the sentences are written on the server side and the connection side. Thank you for your hard work.
### What is an IP address?
An IP address is a 32-bit size Internet address that consists of four integers from 0 to 255.
IP is an abbreviation for Internet Protocol.
Recommended Posts