本文整理汇总了C++中TCP::ReceiveDataExclamation方法的典型用法代码示例。如果您正苦于以下问题:C++ TCP::ReceiveDataExclamation方法的具体用法?C++ TCP::ReceiveDataExclamation怎么用?C++ TCP::ReceiveDataExclamation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCP
的用法示例。
在下文中一共展示了TCP::ReceiveDataExclamation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
TCP* tcp = new TCP();
try
{
tcp->Startup();
tcp->InitSocket();
tcp->Connect(PORT, HOST);
//cout << "Sleep for 10 sec...\n";
//Sleep(10 * 1000);
//cout << "Wake up!\n";
string login;
cout << "Input yout login: ";
cin >> login;
string password;
cout << "Input yout password: ";
cin >> password;
cout << "Hash is " << myhash(password) << endl;
tcp->SendData(login + ":" + to_string(myhash(password)) + "!");
string ans;
if ((ans = tcp->ReceiveDataExclamation()) != "OK!")
cout << "Incorrect login or password. Good bye.\n";
else
{
while (true)
{
string s;
cout << "0. Exit\n";
cout << "1. Statistic\n";
cout << "2. Start game\n";
cin >> s;
// Exit
if (s == "0")
{
tcp->SendData("EXIT!");
cout << "Server sent: " << tcp->ReceiveDataExclamation() << endl;
break;
}
// Statistic
else if (s == "1")
{
tcp->SendData("STATISTIC!");
if ((ans = tcp->ReceiveDataExclamation()) == "ERROR!")
{
throw Exception("Incorrect command. Correct your program's code!\n");
}
cout << endl;
cout << DeleteLastLeter(ans) << endl;
cout << endl;
}
// Game
else if (s == "2")
{
tcp->SendData("GAME!");
if ((ans = tcp->ReceiveDataExclamation()) == "ERROR!")
{
throw Exception("Incorrect command. Correct your program's code!\n");
}
int lettersCount = atoi(DeleteLastLeter(ans).c_str());
cout << endl;
cout << "The number of letters - " << lettersCount << endl;
cout << endl;
int mistakes = 0;
string guessedWord(lettersCount, '-');
cout << "Word: " << guessedWord << "\t" << "Count of mistakes: " << mistakes << "/6\n";
while (true)
{
string letter;
cout << "Input letter: ";
cin >> letter;
cout << "you has inputed: '" << letter << "'\n";
if (letter.length() > 1)
cout << "Your should input only one letter! Letter '" << letter.at(0) << "' has been sent.\n";
// kostile
string temp;
temp.push_back(letter[0]);
temp.push_back('!');
//cout << "Sending letter '" << temp << "'\n";
tcp->SendData(temp);
if ((ans = tcp->ReceiveDataExclamation()) == "ERROR!")
//.........这里部分代码省略.........