int main (int argc, char *argv[]) { //used bmpserver.c printf ("************************************\n"); printf ("Starting simple server %f\n", SIMPLE_SERVER_VERSION); printf ("Serving bmps since 2012\n"); int serverSocket = makeServerSocket (DEFAULT_PORT); printf ("Access this server at http://localhost:%d/\n", DEFAULT_PORT); printf ("************************************\n"); char request[REQUEST_BUFFER_SIZE]; int numberServed = 0; while (numberServed < NUMBER_OF_PAGES_TO_SERVE) { testEscapeSteps(); int connectionSocket = waitForConnection (serverSocket); // wait for a request to be sent from a web browser, open a new // connection for this conversation // read the first line of the request sent by the browser int bytesRead; bytesRead = read (connectionSocket, request, (sizeof request)-1); assert (bytesRead >= 0); // were we able to read any data from the connection? // using struct to assign and check different variables triordinate dat; //used sscanf since using parsing our function made the program very lond. if(sscanf (request,"GET /tile_x%lf_y%lf_z%d.bmp", &dat.x, &dat.y, &dat.z)){ // print entire request to the console printf (" *** Received http request ***\n %s\n", request); //send the browser specific mandelbrot tile printf (" *** Sending http response ***\n"); serveBMP(connectionSocket, dat); } else { // print entire request to the console printf (" *** Received http request ***\n %s\n", request); //send the browser specific mandelbrot tile printf (" *** Sending http response ***\n"); serveHTML(connectionSocket); } // close the connection after sending the page- keep aust beautiful close(connectionSocket); numberServed++; } // close the server connection after we are done- keep aust beautiful printf ("** shutting down the server **\n"); close (serverSocket); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { printf ("Testing mandelbrot.c\n"); printf("%d\n", escapeSteps (-0.825, -0.825)); testEscapeSteps(); printf ("All tests passed. You are Awesome!\n\n"); printmandle(); return EXIT_SUCCESS; }