Search code examples
linuxnetwork-programmingnetcat

How can I modify the netcat command line to send many requests at once


Let's suppose there is a TCP server listening to port 8080. The client connects and sends, for example, a "hello" message after using the Netcat command:

nc localhost:8080

How can I send the "hello" message 1000 times without me being typing? Can I access the Netcat file and add a 'for' or 'while' loop?


Solution

  • No need to modify nc; just pipe your input to it: yes hello | head -n 1000 | nc localhost:8080.