Java Programming things 101--Network Programming overview

Source: Internet
Author: User
Tags convert domain name to ip address switches port number

13th Chapter Network Programming

Network programming for many beginners, are very yearning for a kind of programming skills, but many beginners because for a long period of time can not enter the door of network programming to give up the part of the learning of technology.

Before Learning Network programming, many beginners may feel that network programming is a more complex system engineering, need to know a lot of basic knowledge related to the network, in fact, these are not very necessary. First of all, ask a question: Do you know how to call a cell phone? Many people may say that certainly, is not just presses the telephone number, dials the telephone, very simple matter! In fact, beginners if the introduction of network programming can also do so simple!

Network programming is the transfer of data between two or more than two devices, such as computers. What programmers do is send data to a designated location, or receive the specified data, which is a narrow network programming category. When sending and receiving data, most programming languages design specialized APIs to implement these functions, and programmers only need to invoke them. Therefore, the basic network programming can be as simple as the telephone.

The following is the beginning of the Java language Network programming technology to learn it.

13.1 Network Overview

Network programming technology is currently a mainstream programming technology, with the increasing trend of networking and network applications in large numbers, so in the actual development of network programming technology has been a lot of use. In this chapter, the simple basic knowledge and practical cases enable the majority of beginners to enter the door of network programming technology, as for the actual practice will be reading advanced books and a lot of practical practice.

13.1.1 Computer Network Overview

The essence of network programming is data transfer between two (or more) devices, such as computers.

According to the definition of computer network, through a certain physical device will be in a different location of the computer network composed of networks, the network contains devices: Computers, routers, switches and so on.

In fact, from the point of view of software programming, the understanding of the physical device does not need to be very deep, as you do not need to be familiar with the communication network at the bottom of the implementation is the same, but when deep into the low-level of network programming, these basic knowledge must be complementary.

Routers and switches make up the core computer network, the computer is only the node on this network and control, through optical fiber, cable and other connections to connect the equipment, thus forming a huge computer network.

The main advantage of the network is sharing: Sharing devices and data, now the most common device sharing devices is printers, a company generally a printer can be shared data is a large number of data stored in a group of machines, other computers over the network access to such data, such as Web sites, bank servers and so on.

If you need to know more about the basics of network hardware, you can read the "computer network" textbook, for the foundation to strengthen, this is not necessary in the basic learning stage, but if you want to be in the field of network programming, it is a necessary basic skills.

For network programming, the most important thing is the communication between the computer and the computer, so the first question is how to find the computer on the network? This requires understanding the concept of IP addresses.

To be able to easily identify each device on the network, 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 stipulates that each IP address consists of 4 0-255 digits, such as 10.0.120.34. Each computer that has access to the network has a unique IP address, which may be fixed, such as a wide variety of servers on the network, or dynamic, such as broadband subscribers using ADSL dial-up access, regardless of how they are obtained or fixed, Each computer has a unique legal IP address after networking, just like every phone number.

However, because the IP address is not easy to remember, so for the convenience of memory, there is a creation of 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 concept of domain name can be compared to the phone book, because the phone number is not convenient memory, so add a name identification number, in the actual call can choose the name, and then dial.

In the network transmission of data, all the IP address as the address identified, so in the actual transmission of data need to convert domain name to IP address, the implementation of this function of the server called DNS server, that is, popular parlance is called domain resolution. For example, when a user enters a domain name in a browser, the browser first requests the DNS server, converts the domain name to an IP address, and then feeds the converted IP address to the browser before making the actual data transfer.

When the DNS server is working properly, using an IP address or domain name can easily find a device in the computer network, such as a server computer. When DNS is not working properly, the device can only be accessed through an IP address. Therefore, the use of IP address more than the domain to general some.

IP addresses and domain names are a good solution to the problem of finding a computer in the network, but in order for a computer to run multiple network programs at the same time, another concept-port is introduced.

Before introducing the concept of ports, first of all look at an example, a general company receptionist will have a phone, each employee will have an extension, so if you need to find this employee, you need to first call the front switchboard, and then turn the extension number. This reduces the cost of the company and facilitates each employee. In this example, the phone number of the receptionist is equivalent to an IP address, and each employee's extension number is the equivalent of a port.

With the concept of a port, each program in the same computer will have a unique port on which to differentiate data sent to each port by port, in other words, a computer that can run multiple network programs concurrently without interfering with each other.

The hardware stipulates that the port number must be located between 0-65535, each port only corresponds to a network program, a network program can use multiple ports. Such a network program running on a calculation, whether the client or server, are at least one port to occupy the network traffic. When receiving data, it is first sent to the corresponding computer, and then the computer forwards the data to the corresponding program based on the port.

With the concept of IP address and port, when network traffic is exchanged, the computer can be found by IP address, and then a unique program on the computer is identified through the port. This allows for the exchange of network data.

However, in the network programming, only the concept of IP address and port is not enough, the following is about the basic network programming related software basics.

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.