Computer network
refers to the different geographic locations of multiple computers with independent functions and their external devices, through the communication lines connected together,
Under the management and coordination of network operating system, network management software and network communication protocol, the computer system of resource sharing and information transmission is realized.
Network Programming
is the data exchange between programs running on different computers that are used to implement network interconnection.
TCP/IP protocol stackApplication LayerTransport LayerNetwork LayerNetwork Interface LayerMost application programmers only involve the application layer and the Transport layer three elements of network communicationIP Address: inetaddressThe identity of the device in the network, not easy to remember, the host name can beTo allow computers in your network to communicate with each other, you must specify an identification number for each computer .This identification number specifies the computer to which the data is to be accepted and the computer that identifies the send, which is the IP address in the TCP/IP protocol. Java provides a class inetaddress for us to use. Port numberThe logical address used to identify the process, and the identity of the different processesPhysical port Nic Portlogical ports We're talking about logical ports.each network program will have at least one logical portThe logical address used to identify the process, and the identity of the different processesvalid ports: 0~65535, where the 0~1024 system uses or retains ports. Transport ProtocolRules of communicationCommon protocols: TCP,UDPUDPThe data source and destination are encapsulated into a packet, and no connection is required;The size of each datagram is limited to 64k; it is unreliable because there is no connection. No need to establish a connection, fastTCPestablishing a connection to form a channel for transmitting data, and transmitting large data in connection ;complete the connection through three handshake, is a reliable protocol, must establish a connection, the efficiency is slightly lower
SocketSocket sockets :? An IP address and port number with a unique identity on the network can be combined to form a uniquely identifiable identifier socket. socket principle mechanism:? There are sockets on both ends of the communication. ? network communication is actually the communication between sockets. ? data is transmitted via IO between two sockets.
UDP Transport
Datagramsocket and Datagrampacket establish the sending end, the receiving end. set up the data package. invokes the Send receive method of the socket. Close the socket. the sending and receiving ends are two separate running programs.
TCP Transport
socket and ServerSocket establish a connection between the client and the server, and the data is transmitted through the IO stream in the socket. Similarly, the client and server side are two separate applications.
-1-7 Java Network Programming Basic Knowledge point computer network TCP/IP protocol stack Communication Prerequisites TCP UDP