Using sockets in Java to communicate with multiple clients

Suppose I have 100 clients in my office I must create an application in which a running main thread is waiting for any client to connect. Once the connection is established, the client's IP address will be sent to the server (I've finished) The server can send messages to any client alone or broadcast messages to all clients (this part of the application is beyond my comprehension.) Please help me

Solution

This sounds like TCP to me If you only want to use one thread, you can use non blocking NiO The library that does a lot of tricky code for you is netty

Note: TCP has provided getremoteaddress() to find the address of the startup client

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>