本文整理汇总了C++中TCPSocket::GetError方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPSocket::GetError方法的具体用法?C++ TCPSocket::GetError怎么用?C++ TCPSocket::GetError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPSocket
的用法示例。
在下文中一共展示了TCPSocket::GetError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TCPSocket tcpsock;
GlobalData *gData = new GlobalData("NULL", &tcpsock);
GeneralHandler ghandler;
tcpsock.Connect("mmavipc.dyndns.org", 6667);
std::cout << tcpsock.GetError() << std::endl;
std::string str;
std::stringstream cTime;
cTime << (long long)time(NULL);
if(!tcpsock.SendData("PASS :test\r\nSERVER services.mmavipc.dyndns.org 0 :NoName Services\r\nEOS\r\n"))
{
std::cout << "Fatal error: " << tcpsock.GetError();
}
GenericBot lolbot("lolbot");
lolbot.JoinChannel("#lol");
//Never do this, for testing purposes only
while(true)
{
bool result = tcpsock.RecvLine(str);
if(!result)
{
std::cout << "Fatal error: " << tcpsock.GetError();
break;
}
std::cout << result << " " << str << std::endl;
int spc = FindSpaceCount(str);
std::string *split = new std::string[spc+1];
int pos = 0;
int oldpos = 0;
for(int i = 0; i < spc+1; i++)
{
pos = str.find(' ', pos+1);
if(i != 0)
{
split[i] = str.substr(oldpos+1, pos-oldpos-1);
}
else
{
split[i] = str.substr(oldpos, pos-oldpos);
}
oldpos = pos;
}
int params = 0;
for(int i = 1; i < spc+1; i++)
{
if(split[i].substr(0, 1) == ":")
{
params = i+1;
split[i] = split[i].substr(1, split[i].length()-1);
for(int j = i+1; j < spc+1; j++)
{
split[i] += " " + split[j];
}
break;
}
}
ghandler.Handle(split, params);
delete [] split;
str = "";
}
std::cin.ignore(10000, '\n');
}