Brief introduction
Network everywhere, the mobile internet era has already come, stand-alone version of the program slowly has no vitality, all the programs must be able to access the network, such as QQ network chat program, Thunder download program, and so on, these programs are to deal with the network, this time will share with you small partners is Java network programming- Socket communication.
Basic knowledge of the network
The conditions that two computers must have to communicate over the network:
A, the unique identification (IP address);
b, the need for a common language (agreement);
C, identify different applications (port number).
The key concepts are as follows:
1. IP Address
The unique identity of each computer, used to differentiate the different hosts in the network, is essential for network communication between the two hosts.
2. Agreement
TCP/IP protocol: the most widely used protocol in the world today . is a collection of multiple protocols at different levels based on TCP and IP. Also known as: TCP/IP protocol family or TCP/IP protocol stack.
Tcp:transmission Control Protocol Transmission Protocol
Ip:internet Protocol Internet Protocol
TCP/IP model (network tiering), layered as:
- Physical layer: Network cable ... And so directly accessible.
- Data Link Layer
- Network layer
- Transport Layer:TCP/IP protocol
- Application layer:HTTP Hypertext Transfer Protocol, FTP File Transfer Protocol, SMTP Simple mail delivery protocol, Telnet remote login service.
3. Port number
- Used to differentiate between different applications ;
- The port number range is 0-65535, where 0-1023 is reserved for the system ;
- The IP address and port number make up the so-called socket, which is the endpoint of the bidirectional communication link between programs running on the network, and is the basis for TCP and UDP.
- Common port number- http:80; ftp:21; telnet:23 (can remember).
---------Network support in Java
For the different levels of network communication, Java provides four main types of network functions:
1. InetAddress: Used to identify hardware resources on the network. is to identify the IP address .
2, URL: Uniform Resource Locator ---can read or write directly to the data on the network through a URL.
3. Sockets: Socket-related class for network communication using the TCP protocol .
4, Datagram: Using the UDP protocol , the data is stored in the datagram, communication through the network.
Directory
Here is a list of the total socket contents, click on the corresponding directory can jump to the corresponding blog post, no accident is more , please gaga attention to the first time to receive updated information Oh ~
There are also suggestions to bookmark This blog Oh, as a directory can easily jump to the corresponding content, more convenient and fast (?ω?) Y
- Application of network-related APIs in "socket Programming" Java
- "Socket Programming" for TCP programming via sockets
- "Socket programming" for UDP programming via sockets (Updated tomorrow)
- "Socket Programming" Socket Summary & Integrated Programming applet
"Socket Programming" Java communication is so refined