I. Overview of network Programming
1, the computer network refers to the different geographical location of multiple computers with independent functions and their external devices, through the communication line, in the network operating system, network management software and network communication Protocol management and coordination, the realization of resource sharing and information transmission of computer systems.
2, network programming is used to realize the network interconnection between the different computers running programs can exchange data.
two, network programming three elements of IP overview IP: The unique identity of each device in the network. Each network terminal has a separate address in the network, and we use this address to transmit data over the network. CMD command:
Ipconfig: view native IP192.168.12.42 ping: Test connection 192.168.40.62 Local loop address: 127.0.0.1 broadcast address: 255.255.255.255 ipv4:4 bytes composed of 4 0-255. About 4.2 billion, 3 billion are in North America, Asia 400 million. At the beginning of 2011 was exhausted. Ipv6:8 Group of 4 16 binary numbers per group.
Ipv6:8 Group of 4 16 binary numbers per group. 1A2B:0000:AAAA:0000:0000:0000:AABB:1F2F 1a2b::aaaa:0000:0000:0000:aabb:1f2f 1a2b:0000:aaaa::aabb:1f2f 1a2b:0000: AAAA::0000:AABB:1F2F 1a2b:0000:aaaa:0000::aabb:1f2f
third, the network programming three elements of the port number overview Port number: Each program on the device unique identity each network program needs to bind a port number, when transferring data in addition to determine which machine to send, but also to the specific program to send. Port number range from 0-65535 to write a network application will need to bind a port number, try to use more than 1024, 1024 or less is basically a system program occupied. Common ports
mysql:3306 oracle:1521 web:80 tomcat:8080 qq:4000 feiq:2425
When two devices are logged into 3 different chat tools at the same time, the message sent by QQ on this computer can be sent to the QQ of another computer accurately because the same application has the same port number.
Iv. Protocol Overview of three elements of Network programming protocol: A set of rules, standards, or conventions established for data exchange in a computer network.
UDP: For no connection, data insecure, fast. The client and server are not differentiated. TCP: Connection-oriented (three-time handshake), data security, slightly lower speed. Divided into client and server. Three-time handshake: The client initiates a request to the server, the server responds to the request, transmits the data
Five, the socket Communication principle diagram
Overview of socket Sockets: A combination of IP addresses and port numbers that have a unique identity on the network can form a uniquely identifiable identifier socket. Sockets are available at both ends of the communication. Network communication is actually the communication between sockets. Data is transmitted via IO stream between two sockets. The socket is created in the application and establishes a relationship with the driver through a binding mechanism, telling itself the corresponding IP and port.