httpserver/sockets.cpp
//------------------------------------------------------------------------------------------------------
// This main loop will wait for the client trying to connect to the given HTTP socket (httpSocket)
// will accept client request (creating client socket "clientConnection"), will read the client HTTP
// request from the client socket, will process this request on the server and will send the reply to the
// client. Will close client socket after sending the reply.
//------------------------------------------------------------------------------------------------------
This main loop will wait for the client trying to connect to the given HTTP socket
will accept client request (creating client socket "clientConnection"), will read the client HTTP
request from the client socket, will process this request on the server and will send the reply to the
client. Will close client socket after sending the reply.
This main loop will wait for the client trying to connect to the given HTTP socket will accept client request ( creating client socket " clientConnection " ) will read the client HTTP request from the client socket will process this request on the server and will send the reply to the client . Will close client socket after sending the reply .
void RequestsLoop(int httpSocket) {
   struct sockaddr s;
   int s_size = sizeof(s);
   do {
	   if(CheckSocket(httpSocket)) { 
	      int clientConnection = accept(httpSocket, &s, &s_size);
		  char val = 1;
	      if(clientConnection >= 0) {
	          ProcessCommandSendReply(clientConnection);
			  shutdown(clientConnection,2);
			  closesocket(clientConnection);
		  }
	  }
   } while(!do_shutdown);
}
void RequestsLoop ( int httpSocket ) { struct sockaddr s ; int s_size = sizeof ( s ) ; do { if ( CheckSocket ( httpSocket ) ) { int clientConnection = accept ( httpSocket , & s , & s_size ) ; char val = 1 ; if ( clientConnection >= 0 ) { ProcessCommandSendReply ( clientConnection ) ; shutdown ( clientConnection , 2 ) ; closesocket ( clientConnection ) ; } } } while ( ! do_shutdown ) ; }
This main loop will wait for the client trying to connect to the given HTTP socket (httpSocket)
will accept client request (creating client socket "clientConnection"), will read the client HTTP
request from the client socket, will process this request on the server and will send the reply to the
client.
This main loop will wait for the client trying to connect to the given HTTP socket ( httpSocket ) will accept client request ( creating client socket " clientConnection " ) will read the client HTTP request from the client socket will process this request on the server and will send the reply to the client .
// Waiting for the client request // This function will read the client HTTP request and will process it on the // Discover server. Will send the reply to the client. // We do not need this client connection anymore.