"Java" Java Socket Programming (1) basic terminology and concepts

Source: Internet
Author: User

1. Computer network

A computer network consists of a group of machines connected by a communication channel (communication channel) . These machines are called: hosts (hosts) and routers (routers):

  • communication channel -a means of transmitting a byte sequence from one host to another (wired, wireless (WiFi), etc.).
  • host -The function is the computer that runs the program.
  • Routers --the role is to transfer or forward information from one communication channel to another communication channel.

TCP/IP network communication flowchart:

2. Packet Packets
  • Packet Packets- a sequence of bytes created and interpreted by the program in a network environment.

3. Agreement

 The protocol is equivalent to the mutual communication, and the Protocol stipulates the way of exchanging packet packets and their implication.

The protocol used by the Internet is the TCP/IP protocol , and the TCP/IP protocol family mainly includes :

  • IP Protocol (Internet Protocol, Internet Protocol)
  • TCP Protocol (Transmission Control Protocol, transmission protocol)
  • UDP Protocol (User Datagram Protocol, Subscriber Datagram Protocol)

IP protocol

  • IP Protocol --is the only protocol in the TCP/IP protocol that belongs to the network layer . Transfer data from one host to another host computer.
  • IP Protocol -provides a data service : Each group of packet packets has a network of independent processing and distribution , similar to a letter or parcel sent through the postal system.
  • IP Protocol -is a "best effort"(best-effort) protocol: It attempts to distribute each packet packet, in the network transmission process, the occasional loss of the message is the order of the message is disrupted, or repeated sending the message.

above the IP protocol layer is the Transport Layer (transport layer), which provides two Optional protocols: The TCP protocol and the UDP protocol , both of which are based on the services provided by the IP layer and are also known as "end-to-end transport protocols (End-to-end Transport protocol) "uses different ways of transmitting data depending on the requirements of the Application Protocol (application protocol). Both have a common function: addressing. the address used by the TCP protocol and the UDP protocol, called the port number, is used to differentiate between different applications of the same host.

TCP protocol

 The TCP protocol detects and recovers packet loss, duplication, and other errors that may occur in the host-to-host channel provided by the IP layer. The TCP protocol is a connection-oriented (connection oriented) protocol: Before using it for communication, a TCP connection is first established between two applications, which involves a handshake message between the TCP parts of the two hosts that communicate with each other (handshake message ) of the Exchange.

UDP protocol

  The UDP protocol does not attempt to fix the errors generated by the IP layer, it simply expands the IP protocol, "best effort" data services, enabling it to work between applications rather than between hosts. Applications that use the UDP protocol need to be prepared for handling problems such as packet loss, sequence confusion, and so on.

4. About the Address

In the TCP/IP protocol, two pieces of information are used to locate a specified program: Internet address and port number, range 1-65535. The former is used by the IP protocol, which is parsed by the transport Protocol (TCP/UDP).

Internet addresses are made up of binary numbers in two forms: IPv4 (32-bit) and IPV6 (128-bit). For ease of use, the two versions of the IP protocol have different representations:

  • The IPv4 address is represented as a set of 4 decimal numbers, separated by dots for every two numbers, which is called the Point form (Dotted-quad).
  • The 16 bytes of the IPv6 address are represented by several sets of 16 decimal digits, separated by semicolons, each representing two bytes in the address.

  Loopback address

Loopback addresses (loopback address) are assigned a special loopback interface (loopback interface), a loopback interface that is a virtual device that simply returns the message sent to it to the sender immediately . As in IPv4:127.0.0.1

5. Domain name System,dns and local configuration database

DNS is a distributed database that maps domain names such as www.baidu.com to real Internet addresses and other information. The DNS protocol allows hosts connected to the Internet to obtain information from the DNS database via TCP or UDP protocol.

A local configuration database is typically a mechanism that is related to a specific operating system and is used to map local to Internet addresses.

6. Client and server

The two terms, client and server, represent both of the roles:

  • The client is the initiator of the communication, and the server program passively waits for the client to initiate the communication and respond to it.
  • The client and the server make up the application .

7. What is socket (socket)

A socket (socket) is an abstraction layer through which an application sends and receives data, just as an application opens a file handle to read and write data to a stable memory.

The main socket types in the TCP/IP protocol family are:

  • stream socket (stream socket): The transport layer uses the TCP protocol to provide a trustworthy byte stream service
  • Datagram sockets (Datagram sockets): The transport layer uses the UDP protocol to provide a "best effort" datagram service that can send up to 65,500 bytes of data at a time.

Reference: "TCP/IP Socket in Java"

author : Sunny day pig

Origin : http://www.cnblogs.com/IPrograming 

This article is copyright to the author and the blog Garden, Welcome to reprint, but without the author's consent must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to hold legal responsibility.

http://www.cnblogs.com/IPrograming/archive/2012/03/15/Java_Socket_1.html

/blockquote>

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.