TCP服务器,该怎么解决

TCP服务器
例如TCP服务器与多个客服端建立了链接,同时TCP服务器还处在accept()阻塞下,等待新的客服端链接。
现在我想向已连接的客服发送数据指定的数据。
用C++封装成类:
class server
{
public:
    start(…);       // 启动服务器
    sendto(…);      // 向指定的已连接客服发送指定数据
    sendtoall(…);   // 向所有已连接客服发送指定数据
}

server::start(..)
{
    socket();
    bind();
    listen();
    while(1)
    {
         accept();
     }   
}
TCP服务器启动后就就一直处理accept()去了,根本没有机会去发送数据

感兴趣可以了解一下我最近写的一个小Server。

https://github.com/liangdong/Server

TCP服务器,该怎么解决

相关文章:

你感兴趣的文章:

标签云: