#include "NET_Master.h" main () { // socketStartup(); // Start a server on port 7000 NET_Master master(7007); NET_Client *cli; char buf[1000000]; int bufsize=1000000; while (1) { // See if there are new connections master.checkNewConnection(); // Read one message bufsize=1000000; strcpy(buf,"****"); cli = master.readNetMsg(buf,&bufsize); // If something came in respond if (cli!=NULL) { printf ("%s : %s : Client # %d : Msg len %d : %s\n", cli->remoteHostname(),cli->clientName, master.getClientNum(cli), bufsize, buf); fflush(stdout); // Echo back to client cli->writeNetMsg(buf,bufsize); // Print locally } else if (bufsize==0) // Someone hung up { puts ("Goodbye!"); } // Don't waste CPU usleep(100000); } //socketCleanup(); }