unsigned int opt=1;
if ((fd=socket(AF_INET,SOCK_STREAM,0))==-1) {
- Error("proxyscan",ERR_ERROR,"Unable to open listening socket (%d).",errno);
+ Error("nickrate",ERR_ERROR,"Unable to open listening socket (%d).",errno);
return -1;
}
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &opt, sizeof(opt))!=0) {
- Error("proxyscan",ERR_ERROR,"Unable to set SO_REUSEADDR on listen socket.");
+ close(fd);
+ Error("nickrate",ERR_ERROR,"Unable to set SO_REUSEADDR on listen socket.");
return -1;
}
sin.sin_port=htons(portnum);
if (bind(fd, (struct sockaddr *) &sin, sizeof(sin))) {
- Error("proxyscan",ERR_ERROR,"Unable to bind listen socket (%d).",errno);
+ close(fd);
+ Error("nickrate",ERR_ERROR,"Unable to bind listen socket (%d).",errno);
return -1;
}
listen(fd,5);
if (ioctl(fd, FIONBIO, &opt)!=0) {
- Error("proxyscan",ERR_ERROR,"Unable to set listen socket non-blocking.");
+ close(fd);
+ Error("nickrate",ERR_ERROR,"Unable to set listen socket non-blocking.");
return -1;
}
socklen_t addrsize=sizeof(sin);
char buf[20];
int newfd;
- if ((newfd=accept(fd, (struct sockaddr *)&sin, &addrsize))>0) {
+ if ((newfd=accept(fd, (struct sockaddr *)&sin, &addrsize))>-1) {
/* Got new connection */
sprintf(buf,"%u\n",nicks);
write(newfd,buf,strlen(buf));