/****************************************** * Echo_TCP_Winsock_Client.cpp * Auto-generated by Cliser, Wed Jul 19 14:00:53 EDT 2000 * except for the body of method: * Echo_TCP_Winsock_Client::interactWithClient() * * See http://cs.calvin.edu/~cliser/ for more details. */ #include "TCP_Client_Winsock_Communicator.h" #include "Client.h" class Echo_TCP_Winsock_Client : public Client { public: Echo_TCP_Winsock_Client(const unsigned short port, const string & remoteHost); void interactWithServer(); }; void Echo_TCP_Winsock_Client::interactWithServer() { string messageSent, messageReceived; const string SENTINEL = "quit"; cout << "Enter lines of text (" << SENTINEL << " to quit)\n"; for (;;) { getline(cin, messageSent); if ((messageSent == SENTINEL) || cin.eof()) break; this->send(messageSent); this->receive(messageReceived); cout << messageReceived << endl; } } Echo_TCP_Winsock_Client::Echo_TCP_Winsock_Client(const unsigned short port, const string & remoteHost) : Client("Echo", port, remoteHost) { // optional: // replace these comments with statements // that initialize your client } int main(int argc, char** argv) { unsigned short port = 7; switch(argc) { default: cerr << "Usage: " << argv[0] << " []" << endl; return -1; case 3: port = (unsigned short)atoi(argv[2]); /* fall through */ case 2: Echo_TCP_Winsock_Client myClient(port, argv[1]); myClient.run(); } return 0; }