Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
2  
try socat as listed in this answer –  Jeremy W May 26 '12 at 15:44

1 Answer 1

up vote 10 down vote accepted

Use the "eof" key, CtrlD. When pressed in the middle of a line, it will give to netcat everything that has been input at that point.

share|improve this answer
    
Works, thanks! :) –  thejh May 26 '12 at 16:26
    
+1, but is there no option for opening netcat up the way that it does not buffer anything? –  lpapp Jun 5 at 13:32
2  
@FinalContest: The buffering is done by the tty layer. stty -icanon && nc ... or stty raw && nc ... would disable it. [Note that it must be run together, otherwise the shell itself would reenable it when displaying the prompt.] –  grawity Jun 5 at 13:52
    
@grawity: awesome, the former works fine, but the latter gets stuck... ctrl-c does not work anymore to quit the session, and I cannot get ctrl-z to work on it either. Is that expected? Also, please update your answer so that we can clean the comments up. –  lpapp Jun 5 at 14:07
1  
@FinalContest: Yeah, raw changes a whole bunch of tty options, one of them being the handling of special "control" keys at tty level. (It is really a "raw" mode, in that it passes everything to the program.) You can use stty -a -F /dev/pts/XX from another tty to see the current parameters. –  grawity Jun 5 at 14:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.