20165236 2017-2018-2 "Java Programming" ninth week study summary
1. Chapter 13 Summary of Textbook Contents
1. URL class
The URL class is an important class in the java.net package. Applications that use URLs to create objects are called client programs. A URL object usually contains the most basic three parts of information: protocol, address and resource.
URL constructor: Create a URL object by using public URL(String spec) throws MalformedURLException.
2. InetAddress class
Representation of address: domain name, IP address;
Get the address of the host on the Internet: Use the static method getByName( String s) of the InetAddress class to obtain an InetAddress object, which contains the domain name and IP address of the host address.
3. Socket
The client program uses the Socket class to create a socket object responsible for connecting to the server;
The construction method of Socket is Socket(String host, int port), where host is the IP address of the server, and port is a port number.
In order for the client to successfully connect to the server, the server must establish a ServerSocket object, the constructor of ServerSocket is ServerSocket(int port), and port is a port number.
Use multi-threading technology: After the server receives a client's socket, it should start a thread dedicated to serving the client.
4. UDP datagram
The basic modes of UDP-based communication are:
Pack the data, called a packet, and send the packet to the destination;
Receive incoming packets (like receiving envelopes), and look at the contents of the packets.
Send data packets: Pack the data with the DatagramPacket class;
Receive data packets: Create an object with another constructor of DatagramSocket, DatagramSocket( int port), whose parameters must be the same as the port number of the data packet to be received; the object mail_in uses the method receive(DatagramPacket pack) to accept the data packet; use DatagramPack Another constructor of the class DatagramPack(byte data[], int length) creates a data packet for receiving data packets.
5. Broadcast datagram
6. Java remote call
Design details of remote objects and their proxies, RMI.
Second, last week's test error summary