remove non ascii whitespaces

This commit is contained in:
JMARyA 2024-01-17 09:44:04 +01:00
parent 598a10bc28
commit 5a6d6c4d13
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
117 changed files with 1928 additions and 1928 deletions
technology/applications/cli/network

View file

@ -4,7 +4,7 @@ wiki: https://en.wikipedia.org/wiki/Netcat
---
# netcat
The `nc` (or `netcat`) utility is used for just about anything under the sun involving [TCP](../../../internet/TCP.md), [UDP](../../../internet/UDP.md), or UNIX-domain sockets. It can open [TCP](../../../internet/TCP.md) connections, send [UDP](../../../internet/UDP.md) packets, listen on arbitrary [TCP](../../../internet/TCP.md) and [UDP](../../../internet/UDP.md) ports, do port scanning, and deal with both IPv4 and IPv6.
The `nc` (or `netcat`) utility is used for just about anything under the sun involving [TCP](../../../internet/TCP.md), [UDP](../../../internet/UDP.md), or UNIX-domain sockets. It can open [TCP](../../../internet/TCP.md) connections, send [UDP](../../../internet/UDP.md) packets, listen on arbitrary [TCP](../../../internet/TCP.md) and [UDP](../../../internet/UDP.md) ports, do port scanning, and deal with both IPv4 and IPv6.
Common uses include:
- simple [TCP](../../../internet/TCP.md) proxies
@ -19,32 +19,32 @@ Common uses include:
| `-6` | Use IPv6 addresses only |
| `-b` | Allow broadcast |
| `-l` | Listen for an incoming connection rather than initiating a connection to a remote host |
| `-N` | shutdown the network socket after EOF on the input. Some servers require this to finish their work |
| `-p <source_port>` | Specify the source port `nc` should use, subject to privilege restrictions and availability |
| `-N` | shutdown the network socket after EOF on the input. Some servers require this to finish their work |
| `-p <source_port>` | Specify the source port `nc` should use, subject to privilege restrictions and availability |
## Examples
### Client/Server Model
On one console, start `nc` listening on a specific port for a connection. For example:
On one console, start `nc` listening on a specific port for a connection. For example:
```shell
nc -l 1234
```
`nc` is now listening on port 1234 for a connection. On a second console (or a second machine), connect to the machine and port being listened on:
`nc` is now listening on port 1234 for a connection. On a second console (or a second machine), connect to the machine and port being listened on:
```shell
nc -N 127.0.0.1 1234
```
There should now be a connection between the ports. Anything typed at the second console will be concatenated to the first, and vice-versa. After the connection has been set up, `nc` does not really care which side is being used as a server and which side is being used as a client. The connection may be terminated using an `EOF` (`^D`), as the `-N` flag was given.
There should now be a connection between the ports. Anything typed at the second console will be concatenated to the first, and vice-versa. After the connection has been set up, `nc` does not really care which side is being used as a server and which side is being used as a client. The connection may be terminated using an `EOF` (`^D`), as the `-N` flag was given.
### Data Transfer
The example in the previous section can be expanded to build a basic data transfer model. Any information input into one end of the connection will be output to the other end, and input and output can be easily captured in order to emulate file transfer.
Start by using `nc` to listen on a specific port, with output captured into a file:
Start by using `nc` to listen on a specific port, with output captured into a file:
```shell
nc -l 1234 > filename.out
```
Using a second machine, connect to the listening `nc` process, feeding it the file which is to be transferred:
Using a second machine, connect to the listening `nc` process, feeding it the file which is to be transferred:
```shell
nc -N host.example.com 1234 < filename.in
```