[Socket programming] Java communication is made in this way. socketjava

Source: Internet
Author: User

[Socket programming] Java communication is made in this way. socketjava
Introduction

The network is everywhere, and the mobile Internet era has already arrived. The standalone version of the program has no vitality. All programs must be able to access the network, such as QQ chat programs and thunder download programs, these programs must deal with the network. This time, we will share with you the network programming in Java-Socket communication.

Basic network knowledge

The two computers must haveCondition:

A. Unique Identifier (IP address );

B. A common language (Protocol) is required );

C. identify different applications (port numbers ).

 

The important concepts are as follows:

1. IP Address

For each computerUnique IdentifierTo distinguish different hosts in the network. It is essential for two hosts to communicate over the network.

2. Agreement

TCP/IP protocol:Currently, the most widely used protocols in the world. It is a set of multiple protocols at different levels based on TCP/IP. Also known as: TCP/IP protocol family or TCP/IP protocol stack.

TCP: Transmission Control ProtocolTransmission Control Protocol

IP: Internet ProtocolInternet Protocol

TCP/IP model (network layer), with the following layers:

 

3. Port Number

  • Used to differentiate different applications;
  • The port number ranges from 0 to 65535, and 0-1023 indicates that the system retains the port number;
  • The IP address and port number constitute the so-called Socket. Socket is the end point of the two-way communication link between programs running on the network, and is the basis of TCP and UDP.
  • Common port: http: 80; ftp: 21; telnet: 23 (memorable ).

 

--------- Network support in JAVA

Java provides four types of network functions for different levels of network communication:

1. InetAddress: used to identify the hardware resources on the network. Is the id ip address.

2. URL: Uniform Resource Locator-you can directly read or write data to the network through the URL.

3. Sockets: Socket-related classes for network communication using the TCP protocol.

4. dataphin: uses the UDP protocol to store data in the Datagram and communicate over the network.

Directory

The directory listing the total content of the Socket can be jumped to the corresponding blog by clicking the corresponding directory.Daily, AddFollowUpdate information is received immediately ~

SuggestionsFavoritesIn this blog, you can easily jump to the corresponding content as a directory, making it more convenient and convenient (• ̀ ω • ́) y

  • [Socket programming] Application of Network-related APIs in Java
  • [Socket programming] implement TCP programming through Socket (updated tomorrow)
  • [Socket programming] Implement UDP programming through Socket
  • [Socket programming] Socket summary & integrated programming applets

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.