Talk about socket sockets in java

                       In java, a very important part is network communication, and socket is a very important part.

                       Post a website that I think explains in detail: https://blog.csdn.net/qq_26399665/article/details/52421723

                       Socket communication process:

                      1. The server creates a socket according to the address type (ipv4, ipv6), socket type, and protocol
                      . 2. The server binds the ip address and port number to the socket.
                      3. The server socket listens for port number requests and is ready to receive connections from clients at any time. When the socket of the server is not opened
                      4. The client creates a socket
                      5. The client opens the socket and tries to connect to the server socket according to the server ip address and port number
                      6. The server socket receives the client socket request, passively opens it, and starts to receive the client request until the client returns connection information. At this time, the socket enters the blocking state. The so-called blocking means that the accept() method does not return until the client returns the connection information, and starts to receive the next client understanding request
                      . 7. The client connects successfully and sends the connection status information to the server.
                      8. The server accepts The method returns, the connection is successful
                      9, the client writes information to the socket
                     10, the server reads information
                     11, the client closes
                     12, the server closes

 

Attached:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738598&siteId=291194637