当前位置: 首页>>代码示例>>C++>>正文


C++ SocketHandler::Add方法代码示例

本文整理汇总了C++中SocketHandler::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketHandler::Add方法的具体用法?C++ SocketHandler::Add怎么用?C++ SocketHandler::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketHandler的用法示例。


在下文中一共展示了SocketHandler::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
    }
}
开发者ID:JerkWisdom,项目名称:zpublic,代码行数:31,代码来源:https.cpp

示例2: main

int main(int argc, char *argv[])
{
	SocketHandler h;
	ListenSocket<IOSocket> l(h);
	l.Bind(12344);
	h.Add(&l);
	IOSocket sock(h);
	sock.Open("192.168.7.4", 12344);
	h.Add(&sock);
	while (!quit)
	{
		h.Select(1, 0);
	}
}
开发者ID:J0nath4n,项目名称:mxoemu,代码行数:14,代码来源:crlf.cpp

示例3: main

int main(int argc, char *argv[])
{
    int input,x;
    SocketHandler h;
    ListenSocket<DisplaySocket> l(h);
    std::string text = argc > 1 ? argv[1] : "";
    l.Bind(12346);
    h.Add(&l);
    pid_t pid = fork();
    if (pid != 0) {
        while (!done) {
            x = scanf("%d",&input);
            if (input == 1) {
                done = 1;
                kill(pid, SIGTERM);
            }
        }
    } else {
        while (1)
        {
            h.Select(1, 0);
            printf("dada\n");
        }
    }
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:25,代码来源:receive_test.cpp

示例4: 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();
}
开发者ID:J0nath4n,项目名称:mxoemu,代码行数:11,代码来源:sloppy_http.cpp

示例5: 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);
	}
}
开发者ID:killvxk,项目名称:WebbrowserLock,代码行数:15,代码来源:secure_server.cpp

示例6: 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);
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:15,代码来源:server.cpp

示例7: 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();
}
开发者ID:amirkrifa,项目名称:BitHoc,代码行数:16,代码来源:socket.cpp

示例8: 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);
		}
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:16,代码来源:client.cpp

示例9: run

    void run ()
    {
        SocketHandler h;

        // Launch the RA listener socket
        ListenSocket<RASocket> RAListenSocket (h);
        bool usera = sConfig.GetBoolDefault ("Ra.Enable", false);

        if (usera)
        {
            port_t raport = sConfig.GetIntDefault ("Ra.Port", 3443);
            std::string stringip = sConfig.GetStringDefault ("Ra.IP", "0.0.0.0");
            ipaddr_t raip;
            if (!Utility::u2ip (stringip, raip))
                sLog.outError ("MaNGOS RA can not bind to ip %s", stringip.c_str ());
            else if (RAListenSocket.Bind (raip, raport))
                sLog.outError ("MaNGOS RA can not bind to port %d on %s", raport, stringip.c_str ());
            else
            {
                h.Add (&RAListenSocket);

                sLog.outString ("Starting Remote access listner on port %d on %s", raport, stringip.c_str ());
            }
        }

        // Socket Selet time is in microseconds , not miliseconds!!
        uint32 socketSelecttime = sWorld.getConfig (CONFIG_SOCKET_SELECTTIME);

        // if use ra spend time waiting for io, if not use ra ,just sleep
        if (usera)
        {
            while (!World::IsStopped())
            {
                h.Select (0, socketSelecttime);
                checkping ();
            }
        }
        else
        {
            while (!World::IsStopped())
            {
                ACE_Based::Thread::Sleep(static_cast<unsigned long> (socketSelecttime / 1000));
                checkping ();
            }
        }
    }
开发者ID:repka,项目名称:mangos,代码行数:46,代码来源:Master.cpp

示例10: 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);
	}
}
开发者ID:J0nath4n,项目名称:mxoemu,代码行数:17,代码来源:scanr.cpp

示例11: Run

void ResolvServer::Run()
{
//  StdoutLog log;
    SocketHandler h;
    ListenSocket<ResolvSocket> l(h);

    if (l.Bind("127.0.0.1", m_port))
    {
        return;
    }
    h.Add(&l);

    m_ready = true;
    while (!m_quit && IsRunning() )
    {
        h.Select(0, 500000);
    }
    SetRunning(false);
}
开发者ID:Bootz,项目名称:TC-One,代码行数:19,代码来源:ResolvServer.cpp

示例12: main

int main()
{
	SocketHandler h;
	ListenSocket<DisplaySocket> l(h);
	StdoutLog log;

	h.RegStdLog(&log);

	if (l.Bind(9001))
	{
		exit(-1);
	}
	h.Add(&l);
	h.Select(1,0);
	while (!quit)
	{
		h.Select(1,0);
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:19,代码来源:server_errlog.cpp

示例13: 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);
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:19,代码来源:server6.cpp

示例14: 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();
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:21,代码来源:sslclient.cpp

示例15: 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);
	}
}
开发者ID:andhikanugraha,项目名称:tetembakan,代码行数:22,代码来源:client6.cpp


注:本文中的SocketHandler::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。