10th Week Study Summary

Source: Internet
Author: User

20145339 Tong Zudaj Java 10th Week Study summary of learning Contents
  • The essence of Network Programming Network programming is the data transfer between two (or more) devices (such as computers).
  • Computer network routers and switches constitute the core computer network, computers are only the nodes and control of the network, through the optical fiber, network cables and other connections to connect the device, thus forming a huge computer network.
  • The main advantage of sharing a network is sharing: Sharing devices and data, and now the most common device for sharing devices is the printer.
  • IP address for network programming, the most important thing is the communication between computer and computer, so the first problem is how to find the computer on the network? This requires understanding the concept of IP addresses. Each device in the network will have a unique digital ID, which is the IP address. In the computer network, the name IP address is now defined as the IPV4 protocol, which specifies that each IP address consists of a number of 4 0-255, such as 10.0.120.34. Each computer that accesses the network has a unique IP address, which can be either fixed or dynamic.
  • domain name but because the IP address is not easy to remember, so in order to facilitate memory, has created another concept-domain name, such as Sohu.com. An IP address can correspond to multiple domain names, and a domain name can only correspond to one IP address. The data transmitted in the network, all with the IP address as the address identification, so in the actual transfer of data before the need to convert the domain name to an IP address, the implementation of such a function of the server called a DNS server, that is, popular parlance is called Domain name resolution. The use of IP addresses is more common than domain names.
  • Port has the concept of port, in the same computer each program corresponds to a unique port, so that a computer can be on the port to distinguish the data sent to each port, in other words, a computer can run multiple network programs concurrently, without interference between each other. With the concept of IP address and port, when the network communication is exchanged, you can find the computer by IP address, and then identify a unique program on this computer by port. This allows for the exchange of network data.
  • Network communication Model network communication is based on the "request-response" model. In network communication, the first program to initiate the communication is called the client program, which is called the client, and the program waiting for the connection in the first communication is referred to as the server side (server) program, or server. Once the communication is established, the client and server side are exactly the same, without the essential difference.
  • The two programs in client and server-side network programming are the client and server side respectively. The structure of this network programming is called the client/server structure, also called the client/server structure, or the C/s structure, the structure of using the browser as the client is called the browser/server structure, also called the browser/server structure, referred to as B/s structure. In short, the C/s structure and b/s structure is now the two common network programming structure, b/s structure is actually a special C/s structure. In-peer programs include both client programs and server-side programs.
  • protocol format to write protocol format? The answer is random. As long as this protocol format can generate a unique encoding, according to the code can only parse the contents of the sending data. In the actual programming of the network program, the most troublesome content is not the data sending and receiving, because this function in almost all of the programming language provides a packaged API to call.
  • Network communication Way of network communication mainly have two kinds: in the network communication, the TCP way is similar to the telephone, uses this kind of way carries on the network communication, needs to establish the specialized virtual connection, then carries on the reliable data transfer, if the transmission failure, the client will automatically resend the data. And the UDP way is similar to sends the text message, uses this way carries on the network communication, does not need to establish the specialized virtual connection, the transmission is not very reliable, if sends the failure the client cannot obtain. Because TCP needs to establish a dedicated virtual connection and verify that the transmission is correct, TCP is a bit slower to use, and the amount of data that is transmitted is slightly larger than UDP. On the use of TCP or UDP network communication, network programming is composed of the client and the server side.
  • The programming of client is mainly implemented by three steps: 1, network connection 2, Exchange data 3, close network connection
  • server-side programming server-side programming steps and the client is different, is implemented by four steps, followed by: 1, listening port 2, get connection 3, Exchange data 4, close the connection
  • The basic API for java.net and network programming is located in the java.net package, which contains a basic network programming implementation, which is the basis for network programming. The package contains both the underlying network programming classes and the encapsulated specialized processing classes for web-related
  • TCP Mode is a basic network class--inetaddress class. The function of this class is to represent an IP address and to include an IP address and domain name-related action method inside the class. In the Java language, the network programming of TCP is provided with good support, in the actual implementation, the Java.net.Socket class represents the client connection, and the Java.net.ServerSocket class represents the server-side connection.
  • Network Programming in the client network programming, the first need to establish a connection, in the Java An object in the API Java.net.Socket class represents a network connection, so a client network connection is created, which is the object that creates the socket type, which represents the network connection, and throws an exception if the local network is not connected when the connection is made, or if the server-side program is not turned on. In the Java language, the data transfer function is implemented by Java IO, which means that only the input and output streams need to be obtained from the connection, and then the data that needs to be sent is written to the output stream of the connection object, and the data is read from the input stream after the send is complete. The data is written to the output stream, which is sent by the system, and then the server-side feedback is read from the input stream.
  • multiple data exchange So how do you make a connection and do multiple data exchanges? In fact, it is very simple, after establishing a connection, the logic of data exchange is written into a loop. This way, the connection will not be closed as long as the loop does not end. According to the client implementation of the logic, can also be reused server-side connection, the implementation of the principle is the server-side data exchange logic written in the loop can be,
  • UDP mode The UDP network programming also obtains the good support in the Java language, because it does not need to establish the special connection during the transmission data the characteristic, therefore the implementation structure and the TCP method design in the Java API is not quite the same. Of course, the classes that need to be used are also included in the java.net

10th Week Study Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.