Internet
1, IP is the English internet Protocol (network interconnection between the agreement) abbreviation, Chinese Jane is called "Network Association", namely for the computer network interconnection for communication and design of the agreement. (Network layer)
2, TCP is a connection-oriented communication protocol, TCP provides reliable and error-free data transmission between two computers. (Transport Layer)
3, UDP is connectionless communication protocol, UDP does not guarantee the transmission of reliable data, but can send data to several targets, receive data from several sources. (Transport Layer)
4, socket is the network driver layer provided to the application programming interface and a mechanism. The socket is created in the application, establishes a relationship with the driver through the binding mechanism, and tells itself the corresponding IP and port. The data that the application sends to the socket is then sent to the driver by the socket to the network. After the computer receives data related to the ip+port of the socket from the network, the application can extract the received data from the socket by giving it to the socket by the driver. The network is this way through the socket to send and receive data.
5, Java, respectively, for UDP and TCP two kinds of communication protocols provide the corresponding programming classes, These classes are stored in the java.net package, corresponding to UDP datagramsocket, and TCP ServerSocket (for server-side) and sockets (for clients).
6, Tcp-socket Model:
7, Udp-socket Programming Method:
A, through the Datagrampacket class object to wrap the data, including IP, Port, data.
B, by Datagramsocket class objects to send Datagrampacket class objects,
Datagramsocket.send (Datagrampacket p);
C, by Datagramsocket class objects to receive Datagrampacket class objects,
Datagramsocket.receive (Datagrampacket p);
D, according to the need for the Datagrampacket class object data processing.