201621123042 Java Programming 13th operations

Source: Internet
Author: User

1. Summary of this week's study

Summarize multiple web-related content in the way you like (mind Mapping, OneNote, or others).

2. Add network functions to your system (shopping cart, library management, landlords, etc.)-group complete

To allow your system to be used by multiple users over the network, you need to add network functionality to your system.
2.1 What network functions do you want to add to your system? What is the design idea?
A: In order to enable the shopping cart system to be accessed by multiple clients simultaneously, using multithreading and TCP technology, create a net class, create a socket for the ServerSocket object in the class, and create a Threadserver class to implement multithreading.

2.2 What information does the system pass through the network? What is the format of the information?
A: The system through the network to the client or server using IO flow to the other side, the information using InputStream and OutputStream storage, and then use scanner and printwriter packaging transmission.

2.3 Does your network module use TCP or UDP technology? What are the common classes in a module?
A: TCP technology, commonly used classes are Sreversocket class and socket class, Runable class, thread class.

2.4 Network communication part of the source code and run, and to do a simple explanation.
Note: If you do not write a client, you can use telnet or * * Network debugging Assistant * To do the client.
NET class:

Main function:

Thread class:

2.5 Choose: Use the Client access system you wrote. Describe the core code inside.
2.6 Choose to do: Is there a multi-threaded conflict or synchronization problem in the system?

3. Code cloud and PTA3.1 Statistics The amount of this week's work done

The weekly code statistics need to be fused into a single table.
| weekly | Total code Volume | New Code Volume | Total Files | new file number |
|--------|------|-------|------|-------|
|1|44|44|2|2|
|2|213|213|10|5|
|3|417|204|10|5|
|5|676|259|17|7|
|6|1071|405|24|7|
|7|1780|709|30|6|
|8| 1900|120|35|5|
|9|2335|435|41|6|
|10|2767|432|48|7|
|11|3321|595|57|9|
|12|3601|280|63|6|
|13|4131|531|67|4|
|14|4537|4006|73|6|

Option: 4. Network Learning Guide (the following job content is selected) 1. Network Fundamentals

1.1 Comparison ping www.baidu.com with ping cec.jmu.edu.cn , how does the analysis return result differ? Why is there such a difference?
A: The estimated time of the round trip is different, because www.baidu.com is farther from the machine and cec.jmu.edu.com is closer to the local machine.

1.2 telnet bbs.newsmth.net , what port number does this command connect to the remote host?
Answer: The default port for Telnet is 23

1.3 telnet cec.jmu.edu.cn 80 , try to answer: what do you see from the screen? Is the content returned from the home page of cec.jmu.edu.cn? What will I return if I try to use GET /index HTTP/1.0 a command? See the experimental Task Book topic 1.
Answer: Nothing, GET /index HTTP/1.0 after using the command,

1.4 Start the Connectionwatcher, and then start a number of Internet-enabled programs (such as QQ, Telnet, browser, etc.), to see what the computer on the Internet, what port is used? What ports does QQ use to interact with those remote IPs, where are these IPs distributed? What protocols are used for communication?
A: NetEase cloud music uses 6003 port, QQ browser uses 8080 port, WPS uses 56625 and 56624 port
QQ uses 8080-port and 80-port, interacting with TCP and UDP protocols.

1.5 What are some of the essential information required to write a network program?
ip+ Port, network protocol, input/output stream

    • Reference: Experimental Task Book-topic 1
2. Writing a TCP client program

2.1 Refer to Sockettest.java to write a simple connection to the remote server applet Client.java, you can receive and display the information sent by the server. The remote host IP and port number must first be specified on the console at startup. (, show your own school number).
For:

2.2 Change the URL of the program to Bbs.newsmth.net, the port number to 23, and observe the return result again? Try to execute telnet bbs.newsmth.net 23 , comparing the returned results.
A: The results of both are roughly the same

2.3 Change the URL of the program to cec.jmu.edu.cn, and change the port number to 80 to see the results returned. No return results, why? How do I change the code to display properly? Optional: Why does it return garbled characters? How to solve?
A: You should use the Get/index http/1.0 command because there is no declaration of which protocol to communicate with.
Garbled mainly because the default character set on Eclipse is GBK, and the character set on the Web page is not, through the Baidu know how to modify the character set, after modification there is no garbled.


(Modify character Set)

2.4 Start the Network debugging assistant, set it to TCP Server, and start as shown (do not appear in the job)
[The picture crosses ... (image-db4025-1513150102054-0)]
Use Client.java this server to send information to the client by attempting to connect to the TCP server. (Key code and run result)
For:

2.5 Answer: Now Client.java can only receive information, can be modified Client.java so that it can interact with the server (the server can send information to Client,client can also send information to the server), write about the idea, do not run.
A: To achieve client-server interaction, you need to use the knowledge of a multi-process, create two threads, respectively, to implement their run method, a client to send data to the server, an implementation of the server to send data to the client.

2.6 Optional: implementation 2.5. Intercept the key code and explain it.

    • Reference: Experimental Task book-topic 2
3. ServerSocket and TCP Server

3.1 Simple single thread menuserver, title 3.1-3.4. (Key code and run, including the school number) can use the Network debugging assistant, set it to TCP Client (IP and port fill your menuserver IP and port), connect your menuserver. One of them 文件搜索功能 is optional.
For:

3.2 Multi-threaded menuserver (intercept key code to prove that you are a multithreaded server, use multiple Telnet connection tests).

3.3 Optional: Menuserver of graphical interface

    • You can control the startup stop of the server, view the basic information of the client link (IP, port, link time)
    • Expand: Disconnect a client from the server and view the client-side log records sent to the server
    • Reference: Experimental Task book-topic 3
    • Reference: EchoServer.java ,ThreadedEchoServer.java (多线程服务器)
4. UDP server

4.1 Retrofit 3.1 or 3.2 to transform it into a UDP-based menuserver. (The key code of the TCP server that distinguishes the topic 3, need to truncate a large map, include the number, do not run the interface). You can use the Network debugging assistant to impersonate a UDP client, set it to UDP , and fill it 本机IP与端口 远程服务器的IP与端口 .

4.2 Compared to the corresponding TCP-based menuserver, what is the main difference? In order to connect multiple clients, do you have to use multithreading technology? How do you differentiate between clients if you don't use them?

    • Reference:UDPServer.java
5. Discussion topic: Network Program and Flow

5.1 The program written earlier uses a lot of knowledge about the flow. Briefly, what kind of flow should I choose when writing a network program? Java network programming, the relationship between streams. Choose a scene description, such as: simple text chat, file transfer, Application layer protocol server, such as QQ, chat rooms, online games.

6. Code Reading

Read the source code in the Serverandthread directory
6.1 Modify the program, in the GUI interface to display their own school number, and then run the program (, the number of the study). Describe the main functions of this program.
6.2 Draw the structure diagram of the source code (dependencies of each class). and briefly describe the functions of each class.
6.3 Briefly describe the shortcomings of this program and how to improve it.

Option: 7. Web crawler

Writing a web crawler using sockets, URLs, regular expressions, streams, and so on can download images of all URLs on cec.jmu.edu.cn and its included links, crawling to a level not exceeding 5.

Option: 8. Simple search engine (Advanced)

8.1 Write the design ideas. How does the search engine contain several points? The inner core of the implementation of ideas? If you can draw a schema with a frame diagram or flowchart
8.2 Take the Computer Academy website as an example to test. For example, ACM after entering the search, you can extract the pages containing ACM. (Can be used as a course design topic)

5. Extracurricular reading 5.1 Java tutorial:custom Networking

Trail:custom Networking
Mainly see Overview of Networking,working with URLs, all onSockets, all aboutdatagrams

5.2

Introduction to the HTTP protocol

5.3 A simple little reptile

Java编程技巧:小爬虫程序.docx

5.4 Advanced: Use of httpcomponent

Using sockets, URLs, URLConnection in Java, and then following the HTTP protocol, you can also write a small program that communicates with an HTTP server that can query for results. However, the direct use of socket programming is more cumbersome, this time we can use httpcomponent.
Httpcomponent adds ease of use and flexibility compared to the urlconnection of traditional JDK

1. Read the HttpClient tutorial and use Httpcomponent to write some sample programs that are exchanged with the HTTP server 2. Choose to do: use httpcomponent to develop a query results program: User input user name, password, verification code, you can automatically query the academic Office server, get results.
    • Reference: Write a simple HTTP request and return with Java HttpClient, HttpClient use the HttpClient tutorial,

      HTTP Client Website

201621123042 Java Programming 13th operations

Related Article

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.