本文整理汇总了C++中SocketHandler::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::GetCount方法的具体用法?C++ SocketHandler::GetCount怎么用?C++ SocketHandler::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketHandler
的用法示例。
在下文中一共展示了SocketHandler::GetCount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
try
{
SocketHandler h;
if (argc > 1 && !strcmp(argv[1], "-server"))
{
ListenSocket<tSocket> l(h);
l.Bind(4443);
h.Add(&l);
while (h.GetCount())
{
h.Select(1, 0);
}
}
else
{
std::string host = argc > 1 ? argv[1] : "www.alhem.net";
tSocket sock(h, host);
h.Add(&sock);
while (h.GetCount())
{
h.Select(1, 0);
}
}
}
catch (const Exception& e)
{
printf("%s\n", e.ToString().c_str());
}
}
示例2: get_http
std::string get_http(const char *host, int port, const char *request)
{
SocketHandler h;
GetHttp sock(h, request);
sock.Open( host, port );
h.Add(&sock);
while (h.GetCount()) {
h.Select(1, 0);
}
return sock.Response();
}
示例3: main2
int main2()
{
SocketHandler h;
ListenSocket<ServerSocket> ll(h);
if (ll.Bind(443))
{
return -1;
}
h.Add(&ll);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
示例4: main
int main()
{
SocketHandler h;
ListenSocket<ServerSocket> l(h);
if (l.Bind(40001,10))
{
exit(-1);
}
h.Add(&l);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
示例5: SetSlaveHandler
void Socket::SocketThread::Run()
{
SocketHandler h;
h.SetSlave();
h.Add(m_socket);
m_socket -> SetSlaveHandler(&h);
m_socket -> OnDetached();
while (h.GetCount() && IsRunning())
{
h.Select(0, 500000);
}
// m_socket now deleted oops
// yeah oops m_socket delete its socket thread, that means this
// so Socket will no longer delete its socket thread, instead we do this:
SetDeleteOnExit();
}
示例6: main
int main(int argc,char *argv[])
{
if (argc > 1)
{
SocketHandler h;
ClientSocket cc(h,argv[1]);
cc.Open("127.0.0.1",40001);
// Add after Open
h.Add(&cc);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
}
示例7: main
int main(int argc, char *argv[])
{
std::string host = argc > 1 ? argv[1] : "www.alhem.net";
int port = argc > 2 ? atoi(argv[2]) : 80;
SocketHandler h;
for (int i = 1; i < 255; i++)
{
char host[40];
sprintf(host, "10.170.23.%d", i);
tSocket *p = new tSocket(h, host, 23);
h.Add(p);
}
while (h.GetCount())
{
h.Select(1, 0);
}
}
示例8: main
int main()
{
SocketHandler h;
StdoutLog log;
h.RegStdLog(&log);
ListenSocket<ServerSocket> l(h);
l.SetIpv6();
if (l.Bind(40001,10))
{
exit(-1);
}
h.Add(&l);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
示例9: main
int main(int argc,char *argv[])
{
if (argc != 3)
{
fprintf(stderr, "Usage: %s <-hostname> <-port>\n", *argv);
exit(-1);
}
SocketHandler h;
MyClient sock(h);
port_t port = atoi(argv[2]);
if (port == 2222)
{
sock.EnableSSL();
}
sock.Open(argv[1], port);
h.Add(&sock);
while (h.GetCount())
{
h.Select();
}
}
示例10: main
int main(int argc,char *argv[])
{
if (argc < 2)
{
printf("Usage: %s <command>\n",*argv);
return -1;
}
SocketHandler h;
StdoutLog log;
h.RegStdLog(&log);
ClientSocket cc(h,argv[1]);
cc.SetIpv6();
cc.Open("localhost",40001);
// Add after Open
h.Add(&cc);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
示例11: main
int main(int argc,char *argv[])
{
SocketHandler h;
// enable socks4 client
#ifdef ENABLE_SOCKS4
h.SetSocks4Host("somehost.com");
h.SetSocks4Port(1080);
h.SetSocks4Userid("myname.net");
h.SetSocks4TryDirect(false);
#endif
for (int i = 1; i < argc; i++)
{
Get(h,argv[i]);
}
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}