tldr/pages/common/nc.md

32 lines
502 B
Markdown
Raw Normal View History

2014-03-03 10:22:40 +00:00
# nc
> Reads and writes tcp or udp data.
2014-03-03 10:22:40 +00:00
- Listen on a specified port:
2014-03-03 10:22:40 +00:00
`nc -l {{port}}`
- Connect to a certain port (you can then write to this port):
2014-03-03 10:22:40 +00:00
`nc {{ip_address}} {{port}}`
- Set a timeout:
2014-03-03 10:22:40 +00:00
`nc -w {{timeout_in_seconds}} {{ipaddress}} {{port}}`
- Serve a file:
2014-03-03 10:22:40 +00:00
`cat somefile.txt | nc -l {{port}}`
- Receive a file:
2014-03-03 10:22:40 +00:00
`nc {{ip_address}} {{port}} > somefile.txt`
2014-03-08 02:37:44 +00:00
- Server stay up after client detach:
2014-03-08 02:37:44 +00:00
`nc -k -l {{port}}`
- Client stay up after EOF:
2014-03-08 02:37:44 +00:00
`nc -q {{timeout}} {{ip_address}}`