本文整理汇总了C++中MyServer::run方法的典型用法代码示例。如果您正苦于以下问题:C++ MyServer::run方法的具体用法?C++ MyServer::run怎么用?C++ MyServer::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyServer
的用法示例。
在下文中一共展示了MyServer::run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
TRACEON();
if(argc == 2)
{
int port = atoi(argv[1]);
TRACE("Acting as server: port=%d\n", port);
MyServer bs;
bs.run(port);
}
else
if(argc == 4)
{
const char *host = argv[1];
int port = atoi(argv[2]);
TRACE("Acting as client: host=%s port=%d\n", host, port);
BlockSocket bs(host, port);
if(bs.isConnected())
{
TRACE("connected\n");
char s[256];
strcpy(s, argv[3]);
int w = bs.write(s, strlen(s));
if(w != -1)
{
TRACE("wrote %d bytes\n", w);
int r = bs.read(s, sizeof(s));
if(r != -1)
{
TRACE("read %d bytes\n", r);
s[r] = 0;
TRACE("response: '%s'\n", s);
}
else
TRACE("Read error\n");
}
else
TRACE("Write error\n");
}
else
TRACE("Couldn't connect\n");
}
TRACE("Done.\n");
return 0;
}
示例2: main
int main(int argc, char *argv[]) {
int port = atoi(argv[1]);
MyServer server;
server.run(port);
return 0;
}
示例3: main
int main(int argc, const char *argv[])
{
MyServer s;
return s.run();
}