#include #include using namespace wkgl; void main() { char buf[15] = {0}; //Data received buffer. int msgsize = 0; //Message size //Create a server socket that will listen on port 8080 ServerSocket ss( 8080 ); Socket& s = ss.accept(); //Accept a conection //Make sure the connection is valid if ( !s.isConnected() ) { cout << Socket::getLastError() << endl; //If it is a bad connection //close the server socket //and return. ss.close(); return; } //While we are not at the end of the header do { //Set the buffer to NULL memset( buf, NULL, 15 ); msgsize = s.recv( buf, 14 ); //Recieve a portion of the message if ( msgsize < 0 ) //Make sure there was no error { cout << "\n\n" << Socket::getLastError() << endl; break; } else cout << buf; //Output the message } while ( strcmp( &buf[msgsize - 4], "\r\n\r\n" ) != 0 ); cout << endl; //Flush the output buffer. //Send a message to the client s << "Received Header Information."; //Close the sockets. s.close(); ss.close(); }