20165303 ninth week study summary

  • Knowledge points
    Network model:
    1. OSI reference model
    2. TCP/IP reference model
    Network communication elements:
    1. IP address
    2. The port number
    3. Transmission protocol
      Just think, if you want to communicate with Zhang San, the first thing you need to do is to find the host of Zhang San, then how to find it, and what method to complete the communication between the two machines?
      Steps: 1) Find the IP of the other party
      2) The data is to be sent to the application designated by the other party. In order to identify these applications, these network applications are identified with numbers. For the convenience of calling this number, it is called the port.
      Note: The ports here are not actual ports on the physical machine, but logical ports.
      3) Define a communication rule. This communication rule is called a protocol.
      International organizations have defined a common protocol--TCP/IP protocol.
      Port number:
      Features:
      The logical address used to identify the process.
      Valid port numbers: 0—65535, of which 0—1024 are used or reserved ports by the system.
      Transport Protocol: The rules of communication.
      Common protocols: TCP, UDP.
      The difference between TCP and UDP:
      UDP: 1) Encapsulates data, source and destination into data packets without establishing a connection.
      2) The size of each data packet should be limited to 64k
      3) Because there is no connection, it is an unreliable protocol.
      4) No need to establish connection, fast speed.
      UDP is like sending a package in life: item-packaging-posting a logistics list (fill in the sending information: IP+port)--but the address filled in may not exist, so it may be discarded.
      UDP: Feiqiu chat, Lingbo desktop sharing, network video conference
      TCP: 1) Establish a connection to form a data transmission channel.
      2) A large amount of data is transferred in the connection.
      3) The connection is completed through the three-way handshake, which is a reliable protocol.
      4) The connection must be established, and the efficiency will be slightly lower.
      TCP is like a phone call in life: dial - connect (send a connection request) - connect the path, and then the two sides talk.
      TCP: Online download, call
      Socket:
      Scoket is a mechanism provided for network services. There are sockets at both ends of the communication. Network communication is actually communication between sockets.
      Data is transferred between two Sockets through IO.
      UDP transmission (establishing UDP Socket service method):
      1) DatagramSocket and DatagramPacket.
      2) Establish sender and receiver.
      3) Create a packet.
      4) Call the send and receive methods of the Socket.
      5) Close the Socket.
      Note: The sender and receiver are two separate running programs.
  • Script running result

  • Code cloud screenshot

    Code cloud link https://gitee.com/BESTI-IS-JAVA-2018/20165303WeiYujava/tree/master/src

Guess you like

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