本文介绍了在多线程单服务器多客户端应用程序中阻塞套接字v / s非阻塞套接字。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究服务器客户端应用程序,其中服务器将一次服务(sendto + receivefrom)''x''个客户端。为此,我在服务器端创建了x个线程,以便将每个线程专用于一个客户端。在每个线程内部都有一个特定的套接字,仅供其客户端使用。我想这些套接字是非阻塞的,但现在我认为在每个线程中使用阻塞套接字是一个更好的主意。 Blocking Socket持续等待接收数据,每当需要发送任何内容时,都会调用sendto()。在这种情况下使用阻塞Socket是一种好方法还是应该使用非阻塞套接字? :(

等待帮助!!!

I had been working on a Server Client aplication where Server is going to service(sendto + receivefrom)''x'' number of Clients at a time. For this purpose, I have created ''x'' number of threads on Server side so that each thread is dadicated to one single client. Inside each thread there is a specific socket for just for its client. I was thinking to make these sockets non-blocking but now I think using blocking socket inside each thread is a better idea. Blocking Socket continuously waits to receive data and whenever there is a need to send anything, sendto() is called. Is using blocking Socket in such a situation a good approach or should I use non-blocking sockets? :(
Waiting for help!!!

推荐答案


这篇关于在多线程单服务器多客户端应用程序中阻塞套接字v / s非阻塞套接字。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:00