int s;
int yes;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
perror("socket");
return \-1;
}
yes = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
- (char *) &yes, sizeof(yes)) < 0) {
+ (char *) &yes, sizeof(yes)) == \-1) {
perror("setsockopt");
close(s);
return \-1;
memset(&a, 0, sizeof(a));
a.sin_port = htons(listen_port);
a.sin_family = AF_INET;
- if (bind(s, (struct sockaddr *) &a, sizeof(a)) < 0) {
+ if (bind(s, (struct sockaddr *) &a, sizeof(a)) == \-1) {
perror("bind");
close(s);
return \-1;
struct sockaddr_in a;
int s;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
perror("socket");
close(s);
return \-1;
return \-1;
}
- if (connect(s, (struct sockaddr *) &a, sizeof(a)) < 0) {
+ if (connect(s, (struct sockaddr *) &a, sizeof(a)) == \-1) {
perror("connect()");
shutdown(s, SHUT_RDWR);
close(s);
forward_port = atoi(argv[2]);
h = listen_socket(atoi(argv[1]));
- if (h < 0)
+ if (h == \-1)
exit(EXIT_FAILURE);
for (;;) {
if (r == \-1 && errno == EINTR)
continue;
- if (r < 0) {
+ if (r == \-1) {
perror("select()");
exit(EXIT_FAILURE);
}
memset(&client_address, 0, l = sizeof(client_address));
r = accept(h, (struct sockaddr *) &client_address, &l);
- if (r < 0) {
+ if (r == \-1) {
perror("accept()");
} else {
SHUT_FD1;
buf2_avail = buf2_written = 0;
fd1 = r;
fd2 = connect_socket(forward_port, argv[3]);
- if (fd2 < 0)
+ if (fd2 == \-1)
SHUT_FD1;
else
printf("connect from %s\\n",