winsock监听所有网络适配器 [英] winsock listen all network adapters

查看:115
本文介绍了winsock监听所有网络适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如果计算机只启用网络适配器,我的winsock listen会收到所有UDP / TCP消息。


是否有winsock用于侦听所有网络适配器的API,或者我为每个网络连接/适配器创建单独的套接字实例。


您能否为我提供示例以及异步TCP连接并处理多个客户端连接到我的TCP套接字服务器端接受所有带有线程池的客户端。


谢谢,


Naeem





syednaeemahmad

解决方案

您好
naeem ahmad,


<感谢您在此处发帖。


>>是否有winsock API可以监听所有网络适配器,或者我为每个网络连接/适配器创建了单独的套接字实例。


也许你可以尝试开始一个新的线程pas当您接受连接时,向客户端SOCKET发送歌曲。然后使用

监听功能
将套接字置于其正在侦听传入连接的状态。


她是关于带客户端的多线程TCP服务器的示例,你可以参考。


https: //www.codeproject.com/articles/1922/beginning-winsock-programming-multithreaded-tcp-se


>>你能举个例子吗?以及异步TCP连接和处理多个客户端连接到我的TCP套接字服务器端以接受具有任一线程池的所有客户端。


这里也是关于异步TCP的示例。


https://www.codeproject.com/Articles / 466916 / Asynchronous-TCP-Part-1


希望这可能是你的帮助。


最好的问候,

Sera Yu



Hi,

My winsock listen received all UDP/TCP messages if computer have only network adaptor enable.

Is there winsock API to listen on all network adaptor or I have create separate socket instance for each network connection/adaptor.

Can you provide me example as well to asynchronous TCP connect and handle multiple client connectiong to my TCP socket server end to accept all clients with either thread pool.

Thanks,

Naeem


syednaeemahmad

解决方案

Hi naeem ahmad,

thanks for posting here.

>>Is there winsock API to listen on all network adaptor or I have create separate socket instance for each network connection/adaptor.

Maybe you could try to start off a new thread passing to the thread the client SOCKET when you accept a connection. Then use listen function to places a socket in a state in which it is listening for an incoming connection.

Her is a sample about Multithreaded TCP server with client, you could refer to.

https://www.codeproject.com/articles/1922/beginning-winsock-programming-multithreaded-tcp-se

>>Can you provide me example as well to asynchronous TCP connect and handle multiple client connectiong to my TCP socket server end to accept all clients with either thread pool.

Here is also a sample about Asynchronous TCP.

https://www.codeproject.com/Articles/466916/Asynchronous-TCP-Part-1

Hope this could be help of you.

Best Regards,
Sera Yu


这篇关于winsock监听所有网络适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆