Java Socket Communication
Reference to MU-class network: http://www.imooc.com/learn/161
First, the basic knowledge of the network 1.1 communication
1.2 TCP/IP protocol
- TCP/IP is the most widely used protocol in the world
- is a collection of multiple protocols at different levels based on TCP/IP
- Also known as the TCP/IP protocol cluster or the protocol stack
- Tcp:transmission Control Protocol, transmission protocol
- Ip:internet Protocol, Internet Protocol
1.3 TCP/IP model
1.4 IP Address
- To achieve communication between different computers in the network, each machine must have a unique representation of the--IP address
- IP address format: Dotted decimal, for example 192.168.0.1
- 32 bits binary number
- In order to facilitate memory is divided into four segments, eight bits each, the middle with a decimal point separated.
- Each eight-bit binary number is converted to decimal, with a size of 0 to 255.
1.5 Port number
- Used to differentiate between different applications
- 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,socket is the endpoint of the bidirectional communication link between programs running on the network, which is the basis of TCP and UDP. (similar to calling the switchboard and then transferring to the extension number)
- Common default port number, http:80,ftp:21,telnet:23
1.6 Network support in Java
For the different levels of network communication, Java provides four types of network functions
- InetAddress: Used to represent hardware resources on the network
- URL: A Uniform Resource locator that allows you to read or write data directly on the network through a URL
- Sockets: Socket-related classes for network communication using the TCP protocol
- Datagram: Use the UDP protocol to store data in a datagram and communicate over the network
Java Socket Communication---network basics