Network communication is an essential part of the system interaction, whether it is the job interview or work is not around the past, this section we will talk about some knowledge of Java network programming and network programming interview questions.

JavaOOP, Java collection container, Java Exceptions, concurrent programming, Java reflection, Java serialization, JVM, Redis, Spring MVC, MyBatis, MySQL database, message middleware MQ, Dubbo, Linux, ZooKeeper, distributed & data structure and algorithm and other 25 special technical points, are xiaobian in each big factory summed up the interview question, there are a lot of fans rely on this PDF to win many big factory offer, Today, I am here to summarize and share with you! 【 Finished 】

Full version of Java interview questions address: 2021 latest interview questions collection collection.

The serial number project content link
1 The middleware Java Middleware Interview Questions (Latest version 2021) Juejin. Cn/post / 694870…
2 Micro service Java Micro Service Test Questions (updated version 2021) Juejin. Cn/post / 694906…
3 Concurrent programming Java Concurrent Programming Interview Questions (Updated 2021) Juejin. Cn/post / 695053…
4 Java based Java Basics Test Questions (2021 latest edition) Juejin. Cn/post / 695062…
5 Spring Boot Spring Boot Interview Questions (Updated 2021) Juejin. Cn/post / 695137…
6 Redis Redis Interview Questions (Updated 2021) Juejin. Cn/post / 695166…
7 Spring MVC Spring MVC Interview Questions (updated 2021) Juejin. Cn/post / 695166…
8 Spring Cloud Spring Cloud Interview Questions (Updated 2021) Juejin. Cn/post / 695245…
9 MySQL optimization MySQL optimized Interview Questions (2021 update) Juejin. Cn/post / 695246…
10 JVM JVM Performance Tuning Interview Questions (Latest version 2021) Juejin. Cn/post / 695246…
11 Linux Linux Interview Questions (Latest edition, 2021) Juejin. Cn/post / 695287…
12 Mybatis Mybatis Interview Questions (latest version 2021) Juejin. Cn/post / 695287…
13 Network programming TCP, UDP, Socket, Http Network Programming Juejin. Cn/post / 695287…
14 Design patterns Design Mode Interview Questions (latest version 2021) Juejin. Cn/post / 695544…
15 Big data 100 Big Data Interview Questions (the latest version of 2021) Juejin. Cn/post / 695544…
16 Tomcat Tomcat Interview Questions (latest version 2021) Juejin. Cn/post / 695570…
17 multithreading Multi-threaded Interview Questions (Latest edition 2021) Juejin. Cn/editor/draf…
18 Nginx Nginx_BIO_NIO_AIO Interview Questions (Updated 2021) Juejin. Cn/editor/draf…
19 memcache Memcache Interview Questions (Updated 2021) Juejin. Cn/post / 695608…
20 Java exception Java Exception Interview Questions (latest edition, 2021) Juejin. Cn/post / 695644…
21 The Java virtual machine Java Virtual Machine Interview Questions (Latest version 2021) Juejin. Cn/post / 695658…
22 Java collection Java Collection Interview Questions (Latest edition 2021) Juejin. Cn/post / 695684…
23 Git Common Commands Git Common Commands (updated 2021) Juejin. Cn/post / 695692…
24 Elasticsearch Elasticsearch Interview Questions (Updated 2021) Juejin. Cn/post / 695840…
25 Dubbo Dubbo Interview Questions (Latest edition 2021) Juejin. Cn/post / 695842…

1. Start with a day of interviews:

2. What is network programming

3. Two main problems in network programming

4. What is the Network protocol

In order to exchange data in a computer network in an orderly manner, some pre-agreed rules must be followed, such as the format of the data to be exchanged and whether to send a reply message. These rules are called network protocols.

5. Why layer network protocols

  • Simplify the difficulty and complexity of problems. Because the layers are independent from each other, we can break down big problems into smaller ones.
  • Good flexibility. When the technology of one layer changes, the other layers are not affected as long as the layer indirection relationship remains unchanged.
  • Easy to implement and maintain.
  • Promote standardization. In isolation, the functionality of each layer can be described relatively simply

6. Computer network architecture

TCP/IP reference model

TCP/IP Layer 4 protocol (data link layer, network layer, transport layer, application layer)

  • Application layer The application layer is the layer closest to users. It provides application interfaces and network services for computer users. We common application layer network service protocol: HTTP, HTTPS, FTP, TELNET and so on.
  • The transport layer establishes an end-to-end link between hosts. The transport layer provides end-to-end reliable and transparent data transmission services for upper-layer protocols, including error control and flow control. This layer shields the details of the data communication from the lower layer to the higher layer, so that the higher layer users only see a host to host, user-controlled and configurable, reliable data path between the two transmission entities. This is where we usually talk about TCP and UDP. The port number is the “end” here.
  • Network Layer This layer establishes the connection between two nodes through IP addressing, selects the appropriate routing and switching nodes for the packets sent by the transport layer at the source end, and sends them to the transport layer at the destination end according to the correct address. This is commonly referred to as the IP layer. This layer is often referred to as the IP protocol layer. IP protocol is the foundation of the Internet.
  • The data link layer controls the data transmission through some procedures or protocols to ensure the correctness of the transmitted data. The hardware and software that implement these procedures or protocols are added to the physical circuit, thus forming a data link,


1.1 What are TCP/IP and UDP

1.2 Differences between TCP and UDP:

1.3 APPLICATION scenarios of TCP and UDP:

Use UDP for some situations with high real-time requirements, such as games, media communication, real-time live broadcast, even if there are transmission errors can be tolerated; In most other cases, HTTP is used over TCP because the content transmitted is required to be reliable and not lost

1.4 Describe TCP and UDP

1.5 Analysis of application layer protocols running on TCP or UDP

1.5.1 What Is ARP?

1.5.2 What is Network Address Translation (NAT)?

1.5.3 What is the process from the input address to the page?

1.6 TCP three-way handshake

1.6.1 What is the TCP Three-way Handshake

In network data transmission, the transport layer protocol TCP is a reliable transmission to establish a connection. The process by which TCP establishes a connection is called a three-way handshake.

1.6.2 Details of the three-way handshake

1.6.3 Understand the details of the three-way handshake in reality

1.6.4 Can TWO Handshakes Be used to Establish a Connection? Why is that?

1.6.5 Is a four-way handshake acceptable? Why is that?

This will definitely do. Three handshakes will ensure a successful connection, let alone four, but will reduce the transmission efficiency.

1.6.6 What happens if the Client ACK does not reach the server during the Third Handshake?

1.6.7 What If the Connection Is Established but the Client Is Faulty?

The server resets a timer every time it receives a request from the client. The timer is usually set to two hours. If no data is received within two hours, the server sends a probe segment and then sends it every 75 seconds. If there is no response after 10 consecutive probes, the server considers the client to be faulty and closes the connection.

1.6.8 What is the Initial Serial number?

Party A of the TCP connection randomly selects A 32-bit Sequence Number (for example, 1000) as the Initial Sequence Number (ISN) of the data to be transmitted. The ISN is used as the origin to Number the data to be transmitted. In 1001, 1002… In the three-way handshake, the initial serial number is passed to the other party, B, so that when the data is transmitted, B can confirm what data number is legal; During data transmission, A can acknowledge each byte received by B. If A receives B’s acknowledge number 2001, the data numbered 1001-2000 has been successfully accepted by B.

1.7 Four TCP waves

1.7.1 What is the TCP Quadruple Wave

In network data transmission, the transport layer protocol disconnect process is called four waves

1.7.2 Details of the four waves

1.7.3 Realistic Understanding of the details of the three-way handshake The four-way wave of TCP

1.7.4 Why can’t the server send ACK and FIN together and make three waves (what is the meaning of CLOSE_WAIT status)?

When the server receives the disconnection request from the client, it may have some data to send, so it first replies with an ACK, indicating that it has received the disconnection request. After the data is sent, send FIN to disconnect the data transfer from the server to the client.

1.7.5 What happens if the server ACK does not reach the client on the second wave?

If the client does not receive the ACK acknowledgement, it resends the FIN request.

1.7.6 What Is the Significance of Client TIME_WAIT State?

2 Socket

2.1 What is A Socket

  • Two programs on the network exchange data through a bidirectional communication connection, one end of which is called a Socket. Sockets are used to connect a client to a server. Socket is a popular programming interface of THE TCP/IP protocol. A Socket is uniquely identified by an IP address and a port number.
  • However, the Socket supports more than TCP/IP and UDP. Therefore, there is no necessary connection between the two protocols. In the Java environment, Socket programming mainly refers to network programming based on TCP/IP protocol.
  • Socket connection is the so-called long connection, the client and the server need to connect each other, theoretically the client and the server once established the connection will not take the initiative to disconnect, but sometimes network fluctuations are possible
  • Sockets are biased to the bottom. In general, it is rarely used to program directly with sockets, and it is more used at the bottom of the framework.

2.2 Which layer of the network a socket belongs to

2.3 Process of Socket communication

2.4 TCP Socket code example:

Run the server first, then run the client,

  1. Server:
Copy the code

2.5 UDP Socket code example:

2.6 Common classes of sockets


3.1 What is Http?

3.2 Differences and Application Scenarios between Sockets and HTTP

  • Socket connection is the so-called long connection, theoretically the client and the server will not take the initiative to disconnect once established connection;
  • Socket application scenarios: online games, continuous bank interaction, live streaming, online video, etc.
  • An HTTP connection is called a short connection. The client sends a request to the server. After the server responds, the connection is disconnected and waits for the next connection
  • Application scenarios of HTTP: OA service, Internet service, e-commerce, office, website, etc

3.3 What is the HTTP Request Body?

3.4 What Are THE HTTP Response Packets?

3.5 What are the Differences between HTTP and HTTPS?

3.6 HTTPS Working Principle

3.7 How many steps does a complete HTTP request go through?

3.8 How are common HTTP status Codes classified? What are the common HTTP status codes?

3.9 What are the request modes in Http

3.10 Differences between GET and POST Methods

3.11 Comparison between THE HTTP versions

3.12 What is symmetric encryption and asymmetric encryption

3.13 What are cookies and sessions for HTTP?