aboutsummaryrefslogtreecommitdiff
path: root/networking/nc.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /networking/nc.c
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
Major coreutils update.
Diffstat (limited to 'networking/nc.c')
-rw-r--r--networking/nc.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/networking/nc.c b/networking/nc.c
index 63d8c5b19..4888ccceb 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -72,7 +72,7 @@ int nc_main(int argc, char **argv)
72 break; 72 break;
73#endif 73#endif
74 default: 74 default:
75 show_usage(); 75 bb_show_usage();
76 } 76 }
77 } 77 }
78 78
@@ -85,13 +85,13 @@ int nc_main(int argc, char **argv)
85 85
86 86
87 if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) 87 if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc))
88 show_usage(); 88 bb_show_usage();
89 89
90 if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) 90 if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
91 perror_msg_and_die("socket"); 91 bb_perror_msg_and_die("socket");
92 x = 1; 92 x = 1;
93 if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) 93 if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1)
94 perror_msg_and_die ("reuseaddr failed"); 94 bb_perror_msg_and_die ("reuseaddr failed");
95 address.sin_family = AF_INET; 95 address.sin_family = AF_INET;
96 96
97 if (lport != 0) { 97 if (lport != 0) {
@@ -99,17 +99,17 @@ int nc_main(int argc, char **argv)
99 address.sin_port = htons(lport); 99 address.sin_port = htons(lport);
100 100
101 if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) 101 if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0)
102 perror_msg_and_die("bind"); 102 bb_perror_msg_and_die("bind");
103 } 103 }
104 104
105 if (do_listen) { 105 if (do_listen) {
106 socklen_t addrlen = sizeof(address); 106 socklen_t addrlen = sizeof(address);
107 107
108 if (listen(sfd, 1) < 0) 108 if (listen(sfd, 1) < 0)
109 perror_msg_and_die("listen"); 109 bb_perror_msg_and_die("listen");
110 110
111 if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0) 111 if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0)
112 perror_msg_and_die("accept"); 112 bb_perror_msg_and_die("accept");
113 113
114 close(sfd); 114 close(sfd);
115 sfd = tmpfd; 115 sfd = tmpfd;
@@ -120,7 +120,7 @@ int nc_main(int argc, char **argv)
120 address.sin_port = htons(atoi(argv[optind+1])); 120 address.sin_port = htons(atoi(argv[optind+1]));
121 121
122 if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0) 122 if (connect(sfd, (struct sockaddr *) &address, sizeof(address)) < 0)
123 perror_msg_and_die("connect"); 123 bb_perror_msg_and_die("connect");
124 } 124 }
125 125
126#ifdef GAPING_SECURITY_HOLE 126#ifdef GAPING_SECURITY_HOLE
@@ -149,12 +149,12 @@ int nc_main(int argc, char **argv)
149 testfds = readfds; 149 testfds = readfds;
150 150
151 if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0) 151 if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0)
152 perror_msg_and_die("select"); 152 bb_perror_msg_and_die("select");
153 153
154 for (fd = 0; fd < FD_SETSIZE; fd++) { 154 for (fd = 0; fd < FD_SETSIZE; fd++) {
155 if (FD_ISSET(fd, &testfds)) { 155 if (FD_ISSET(fd, &testfds)) {
156 if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) 156 if ((nread = safe_read(fd, buf, sizeof(buf))) < 0)
157 perror_msg_and_die("read"); 157 bb_perror_msg_and_die("read");
158 158
159 if (fd == sfd) { 159 if (fd == sfd) {
160 if (nread == 0) 160 if (nread == 0)
@@ -166,8 +166,8 @@ int nc_main(int argc, char **argv)
166 ofd = sfd; 166 ofd = sfd;
167 } 167 }
168 168
169 if (full_write(ofd, buf, nread) < 0) 169 if (bb_full_write(ofd, buf, nread) < 0)
170 perror_msg_and_die("write"); 170 bb_perror_msg_and_die("write");
171 if (delay > 0) { 171 if (delay > 0) {
172 sleep(delay); 172 sleep(delay);
173 } 173 }