one server multiple clients

后端 未结 4 2020
小鲜肉
小鲜肉 2021-01-22 08:57

I am engaging the following problems:

  1. I need to write a server program, will accept multiple clients
  2. all clients are subscribing the same data from server
4条回答
  •  -上瘾入骨i
    2021-01-22 09:31

    Others have mentioned that you can use the nio library to reduce the number of threads necessary. i just wanted to point out that your current example code will not work. you must use a thread per socket when using the standard io streams. the available() method is pretty much useless (in general) and will not stop your control thread from blocking.

提交回复
热议问题