/****************************************** * Echo_POSIX_Concurrent_TCP_Winsock_Server.cpp * Auto-generated by Cliser, Wed Jul 19 14:00:56 EDT 2000 * except for the body of method: * Echo_POSIX_Concurrent_TCP_Winsock_Server::run() * * See http://cs.calvin.edu/~cliser/ for more details. */ #include "TCP_Server_Winsock_Communicator.h" #include "PThreadsConcurrentServer.h" #include "ServiceThread.h" class Echo_TCP_Winsock_Thread : public ServiceThread { public: Echo_TCP_Winsock_Thread(); void interactWithClient(); }; void Echo_TCP_Winsock_Thread::interactWithClient() { string message; int numCharsReceived; for (;;) { numCharsReceived = this->receive(message); if (numCharsReceived == 0 || message == "") break; this->send(message); } } Echo_TCP_Winsock_Thread::Echo_TCP_Winsock_Thread() : ServiceThread() { // optional: // replace these comments with statements // that initialize your server thread } class Echo_POSIX_Concurrent_TCP_Winsock_Server : public PThreadsConcurrentServer { public: Echo_POSIX_Concurrent_TCP_Winsock_Server(const unsigned short port); }; Echo_POSIX_Concurrent_TCP_Winsock_Server::Echo_POSIX_Concurrent_TCP_Winsock_Server(const unsigned short port) : PThreadsConcurrentServer("Echo", port) { // optional: // replace these comments with statements // that initialize your server } int main(int argc, char** argv) { unsigned short port = 7; switch(argc) { default: cerr << "Usage: " << argv[0] << " []" << endl; return -1; case 2: port = (unsigned short)atoi(argv[1]); /* fall through */ case 1: Echo_POSIX_Concurrent_TCP_Winsock_Server myServer(port); myServer.run(); } return 0; }