int sockfd=-1, pollcount=2;
struct pollfd pollfds[2];
+ memset(pollfds, 0, 2*sizeof(struct pollfd));
pollfds[0].events = pollfds[1].events = POLLIN;
set_alarm(TT.wait);
int temp;
struct sockaddr_in address;
- pollfds[1].fd = 0;
-
// Setup socket
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (-1 == sockfd) perror_exit("socket");
int len = read(pollfds[i].fd, toybuf, sizeof(toybuf));
if (len<1) goto dohupnow;
xwrite(i ? pollfds[0].fd : 1, toybuf, len);
- }
- if (pollfds[i].revents & POLLHUP) {
+ } else if (pollfds[i].revents & POLLHUP) {
dohupnow:
// Close half-connection. This is needed for things like
// "echo GET / | netcat landley.net 80"