Song lixing _ 04_01 Network Programming

Source: Internet
Author: User

 

A song lixing _ 04_01 Network Programming

Java is platform-independent.Programming LanguageIt has the characteristics of "one-time writing and running everywhere", so it is very suitable for network programming. It can be said that no network programming language is better than Java. A computer network is a large-scale and functional network system that connects computers distributed in different geographic regions with dedicated external devices using communication lines, so that many computers can easily transmit information to each other and share hardware, software, data information, and other resources.

"Open System Interconnection Reference Model": This model divides computer networks into seven layers: physical layer, data link layer, network layer, transmission layer, Session Layer, presentation layer, and application layer.

Communication protocols must be defined in computer networks. Speed and transmissionCodeCode structure, transmission control steps, error control, and other standards.

TCP protocol: provides reliable data transmission service rules.

The IP protocol separates and assembles IP data packets. However, the IP protocol does not clearly understand whether packets are successfully sent to the target computer. When the TCP protocol is used to successfully send data packets to the target computer, a confirmation request is sent. If no confirmation is received within a certain period of time, TCP resends the data packet.

IP Address: To achieve communication between different computers in the network, each machine in the network must have a unique identifier, which is the IP address ).

Port: A 16-bit integer used to indicate the communication data is sentProgramProcessing. Therefore, a port is the entrance for applications to communicate with the outside world. It is an abstract software structure, including some data structures and I/O (Basic Input/Output) buffers.

Different applications process data on different ports. Two programs on the same machine cannot use the same port. The port numbers can be from 0 to 65535. Generally, they are divided into three types:

Well known ports: from 0 to 1023, they are closely bound to some services.

Registry port (registered ports): from 1024 to 49151. They are loosely bound to some services.

Dynamic and/or private ports: From 49152 to 65535, these ports are dynamic ports used by applications, which are generally not used by applications.

JDK provides the java.net package for developing network applications. The classes and interfaces under this package are almost all network programming services.

Inetaddress: the object used to describe the IP address

the inetaddress class does not provide a constructor, instead, two static methods are provided to obtain the inetaddress instance
getbyname (string host): obtain the corresponding inetaddress object based on the host.
getbyaddress (byte [] ADDR): obtains the corresponding inetaddress object based on the original IP address.

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.