本文整理汇总了C++中Sock::GetHost方法的典型用法代码示例。如果您正苦于以下问题:C++ Sock::GetHost方法的具体用法?C++ Sock::GetHost怎么用?C++ Sock::GetHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sock
的用法示例。
在下文中一共展示了Sock::GetHost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvalXTCPRecv
void EvalXTCPRecv(const void *obj, qCtx *ctx, qStr *out, qArgAry *args)
{
Sock *s = (Sock *) obj;
int len;
char *line = NULL;
if (args->Count() > 0) {
len = ParseInt((*args)[0]);
len = s->Read(len);
line = s->GetBuf();
} else {
len = s->ReadLine(&line);
}
if (len > 0)
out->PutS(line, len);
else if (len < 0 ) {
if (len == Sock::ERR_TIMEOUT) {
ctx->ThrowF(out, 702, "Timeout while waiting to read data from host %s:%d, %y", s->GetHost(), s->GetPort());
} else {
ctx->ThrowF(out, 702, "Error while reading data from host %s:%d, %y", s->GetHost(), s->GetPort(), GetLastError());
}
}
}
示例2: EvalXTCPSend
void EvalXTCPSend(const void *obj, qCtx *ctx, qStr *out, qArgAry *args)
{
Sock *s = (Sock *) obj;
CStr str = (*args)[0];
int len = s->Write(str, str.Length());
if (len < 0 ) {
if (len == Sock::ERR_TIMEOUT) {
ctx->ThrowF(out, 702, "Timeout while waiting to write data from host %s:%d, %y", s->GetHost(), s->GetPort());
} else {
ctx->ThrowF(out, 702, "Error while writing data from host %s:%d, %y", s->GetHost(), s->GetPort(), GetLastError());
}
}
}