diff --git a/master_server.h b/master_server.h index 77bf587..aa7911a 100644 --- a/master_server.h +++ b/master_server.h @@ -34,6 +34,7 @@ #include #include #include +#include struct repeater{ struct sockaddr_in address; diff --git a/webserv.c b/webserv.c index 221087e..27bee81 100644 --- a/webserv.c +++ b/webserv.c @@ -49,7 +49,6 @@ void *webServerListener(){ struct sockaddr_in servaddr; int yes=1; // for setsockopt() SO_REUSEADDR, below pthread_t thread; - /* Create socket */ if ( (listener = socket(AF_INET, SOCK_STREAM, 0)) < 0 ){ @@ -58,7 +57,7 @@ void *webServerListener(){ } /* Populate socket address structure */ - + memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = inet_addr("0.0.0.0"); @@ -381,7 +380,7 @@ int Return_Resource(int conn, FILE *resource, struct ReqInfo * reqinfo) { if (strstr(reqinfo->resource,".html")){ while(fgets(line,sizeof(line),resource)){ sprintf(sendLine,"%s",htmlReplace(line,reqinfo->resource)); - if ( write(conn, sendLine, strlen(sendLine)) < 1 ){ + if ( send(conn, sendLine, strlen(sendLine),MSG_NOSIGNAL) < 1 ){ syslog(LOG_NOTICE,"Error sending file."); break; } @@ -390,7 +389,7 @@ int Return_Resource(int conn, FILE *resource, struct ReqInfo * reqinfo) { else{ while (!feof(resource)){ c = fgetc(resource); - if ( write(conn, &c, 1) < 1 ){ + if ( send(conn, &c, 1,MSG_NOSIGNAL) < 1 ){ syslog(LOG_NOTICE,"Error sending file."); break; }