52

How can I force netcat to send my input immediately, not just on newlines? I want to test an HTTP parser manually and check how it behaves when header lines are spread across multiple packets.

thejh
  • 1,457

1 Answers1

65

Use CtrlD, which is set by default as the tty eof key. When pressed in the middle of a line, it will give to netcat everything that has been input at that point.

The buffering is actually done by the tty layer and not handled by nc at all. stty -icanon && nc ... would disable the buffering and allow nc to see the data as it is entered into the terminal, at which point it will be sent right away. (Note that the stty and nc commands must be run together, otherwise the shell itself would likely reenable it when displaying its prompt.)

grawity
  • 501,077