Home > Back-end >  UDP concurrent programming of Java socket
UDP concurrent programming of Java socket

Time:05-12

Before using the TCP Socket, through listening ServerSocket can get one-to-one Socket object, then through multi-threaded each thread alone to deal with sending and receiving information,

While (true) {
The Socket Socket=serverSocket. The accept ();//call the accept () method, to start listening, waiting for the client connection
SocketThread SocketThread=new SocketThread (socket);//multi-threaded single handle socket to send and receive
SocketThread. Start ();
}

Now need to change into the UDP Socket, but now do not understand a problem, if there are multiple sender and a receiver, the receiver how to open a thread to handle separately corresponding to the sender to send data and information? Hope bosses to solve it
  • Related