1 Socket Communication Process
==> server-side listening: The server-side socket does not locate the specific client socket, but is waiting for the listening state, real-time monitoring network status.
==> Client Request: The client clientsocket send a connection request, the target is the server-side ServerSocket, so the client clientsocket must know the IP address and port number of the server-side ServerSocket. Used to perform a scan to send a connection request.
==> Connection Confirmation: When the server Socket monitor heard or received a client socket connection request, the server side of the corresponding client connection request, create a new socket, the server socket to send to the client, once the client confirms the connection, the connection is established. (Note: In the connection confirmation phase, the server-side socket even with the client socket connection, still in the listening state, still can accept the other client's connection request, that is, a server side can correspond to multiple clients).
2) Learning Socket class
==>socket Class Learning
Public Socket (addressfamily addressfamily,sockettype sockettype,protocoltype protocoltype);
(This is the create socket for the TCP protocol)
AddressFamily is the network type, generally using addressfamily.internetwork (IPV4);
SocketType represents the socket type, and TCP uses the SocketType.Stream;
ProtocolType represents the protocol used, and TCP uses PROTOCOLTYPE.TCP.
(This is the create socket for the UDP protocol)
AddressFamily is the network type, generally using addressfamily.internetwork (IPV4);
SocketType represents the socket type, UDP uses the Sockettype.dgram;
ProtocolType means the communication protocol used, UDP uses protocoltype.udp;