tech-misc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
nc - unbuffered input
Might there be another soul that desires a netcat with unbuffered input?
usage for unbuffered client mode: nc -B localhost 65535
(I hope the patch comes through ok)
Index: netcat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/nc/netcat.c,v
retrieving revision 1.5
diff -u -p -r1.5 netcat.c
--- netcat.c 9 Feb 2017 21:23:48 -0000 1.5
+++ netcat.c 13 Dec 2018 13:43:55 -0000
@@ -54,6 +54,7 @@ __RCSID("$NetBSD: netcat.c,v 1.5 2017/02
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <termios.h>
#include <time.h>
#include <unistd.h>
#ifdef CRYPTO
@@ -166,6 +167,7 @@ main(int argc, char *argv[])
int errnum;
struct addrinfo proxyhints;
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
+ struct termios t;
#ifdef CRYPTO
struct tls_config *tls_cfg = NULL;
struct tls *tls_ctx = NULL;
@@ -180,7 +182,7 @@ main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN);
while ((ch = getopt(argc, argv,
- "46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:R:rSs:T:tUuV:vw:X:x:z")) != -1) {
+ "46BC:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:R:rSs:T:tUuV:vw:X:x:z")) != -1) {
switch (ch) {
case '4':
family = AF_INET;
@@ -191,6 +193,13 @@ main(int argc, char *argv[])
case 'U':
family = AF_UNIX;
break;
+ case 'B':
+ if (tcgetattr(STDIN_FILENO, &t) < 0)
+ err(1, "tcgetattr");
+ t.c_lflag &= ~ICANON;
+ if (tcsetattr(STDIN_FILENO, TCSANOW, &t) < 0)
+ err(1, "tcsetattr");
+ break;
case 'X':
if (strcasecmp(optarg, "connect") == 0)
socksv = -1; /* HTTP proxy CONNECT */
Home |
Main Index |
Thread Index |
Old Index