20165236 2017-2018-2 "Java Programming" Nineth Week study Summary

Source: Internet
Author: User

20165236 2017-2018-2 "Java Programming" Nineth Week study Summary

The 13th chapter summarizes the contents of the textbook

1. URL class

The URL class is an important class in the java.net package, and the application that uses the URL to create the object is called the client program. A URL object typically contains the most basic three-part information: protocol, address, and resource.

URL Construction method: Create a URL object by using the public URL (String spec) throws Malformedurlexception.

2, InetAddress class

The representation of the address: domain name, IP address;

Get the address of a host on the Internet: use the static method of the InetAddress class Getbyname (String s) to obtain a InetAddress object that contains the domain name and IP address of the host address.

3. Socket SOCKET

The client program uses the socket class to establish a socket object that is responsible for connecting to the server;

The socket is constructed by a socket (String host, int port), the host is the IP address of the server, and port is a port number.

For the client to successfully connect to the server, the server must establish a ServerSocket object, ServerSocket is constructed by serversocket (int port) and port is a port number.

Using multithreading technology: After the server receives a client's socket, it should start a thread dedicated to that customer service.

4. UDP datagram

The basic mode of UDP-based communication is:

Package the data, called a packet, and then send the packet to the destination;

Receive packets that are sent (like receiving envelopes), and then view the contents of the packet.

Send packet: Use the Datagrampacket class to package the data;

Receive packet: create an object with another constructor of Datagramsocket datagramsocket (int port), where the parameters must be the same as the port number of the packet to be received; object Mail_ In use method receive (Datagrampacket pack) to accept the packet, with another constructor method of the Datagrampack class Datagrampack (Byte data[],int Length) creates a packet to receive the packet.

5. Broadcast Data Report

6. Java Remote Call

Design details for remote objects and their proxies and RMI.

Second, last week's summary of the test wrong question

3. The following (AB) method will cause the thread to go into a blocking state? A.thread.sleep () b.wait () c.notify () D.interrupt () 5,the Interrupt () method of the calling thread throws the (CD) exception object? A.illegalstateexceptionb.runtimeexceptionc.interruptedexceptiond.securityexception 12,The following statement about the state of the thread and the life cycle is wrong (BC)A. Do not let the thread call the start () method again until the line has ended the run () method, or the illegalthreadstateexception exception will occur. The B.run () method is responsible for notifying the JVM that there are new threads waiting to be toggled. C. After the execution of Sleep (), the thread goes into a running state and gets the use of the CPU. D. When the blocking state is entered, the thread cannot enter the queued queue. Third, this week study summary this week focused on learning Java network programming, master some URLs, sockets and other classes in the network programming important role, let me have a lot of harvest.

20165236 2017-2018-2 "Java Programming" Nineth Week study Summary

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.