1. Summary of this week's study
2. Written work Q1. Network Fundamentals 1.1 Comparing ping www.baidu.com with ping cec.jmu.edu.cn, what is the difference between analyzing the returned results? Why is there such a difference?
Through experiments, we can draw
Ping www.baidu.co>ping cec.jmu.edu.cn
That's because the data emitted is closer to the JMU server and results
1.2 Telnet bbs.newsmth.net, what port number does this command connect to the remote host?
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 the Get/index http/1.0 command? See the experimental Task Book topic 1.
- There is no content; The return is not cec.jmu.edu.cn home page content
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?
- Thunder NetEase Cloud, Sogou, QQ, the use of 80 ports, 49329 ports and so on. 80 ports were used to interact with the remote IP, using the TCP protocol.
1.5 What are some of the essential information required to write a network program?
sockets, input and output streams, TCP, UDP protocol
Q2. Write 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)
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 perform Telnet bbs.newsmth.net 23, comparing the returned results.
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 to Operate
Because the client and server (cec.jmu.edu.cn) interact through the HTTP protocol, you need to use the GET command to request a message. If you use a socket, you must send the HTTP request yourself, because the URL class can interact directly with the Web server (which encapsulates the code that communicates using the HTTP protocol) and is convenient to use.
2.4 Start the Network debugging assistant, set it to TCP server, and start, and try to use Client.java to connect to the TCP server and use that server to send information to the client. ()
2.5 Answer: Now the 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 a general idea.
Q3. ServerSocket with TCP server 3.1 simple single thread Menuserver, topic 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. The file search function is optional.
3.2 Multi-threaded menuserver (proof you This is a multithreaded server, using Telnet connection).
3.3 Choose: MenuServerQ4 of the graphical interface. UDP Server 4.1 Retrofit 3.1 or 3.2, transforming it into UDP-based menuserver. (Run the interface code, including the school number). You can use the Network debugging assistant, set it to UDP, to fill the local IP and port also to fill the remote server IP and port.
Q5. Discussion topic: Network program and flow 5.1 written before the program used a lot of knowledge of the flow. Briefly, what kind of flow should I choose when writing a network program? Java network programming, the relationship between streams. Scenarios such as: Simple text chat, file transfer, Application layer protocol server, such as QQ, chat rooms, online games.
- When you write a network program, select the stream of input and output streams, and then wrap them in a character stream.
- To the program, the output to the screen, printers, files, etc. are called output, and read from the file, read from the network, received is counted input.
Q6. 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.
Function: Implement a communication connection between a service and multiple clients.
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.
- Insufficient: When the client sends a message, the server knows which line Cheng the message, but the client displays only "client said:" and cannot differentiate between clients.
Option: 7. Web crawler using sockets, URLs, regular expressions, streams, etc. to write a web crawler can be cec.jmu.edu.cn and its included links on all the URLs of the pictures are downloaded, crawl to not more than 5. Option: 8. Simple search engine (Advanced) 8.1 Write design ideas can be. How does the search engine contain several points? The inner core of the implementation of ideas? If you can draw the framework diagram, Flowchart 8.2 to the computer Academy website as an example, to test. For example, after you enter ACM, you can extract pages that contain ACM. (Can be used as a Course design topic) 3. Code cloud codes to submit records
201521044091 Java Programming 13th Week of study summary