You do not want to look confused, the share Tsinghua University graduate Gangster finishing Java network programming interview questions to you

Foreword

It usually develops job interview when the interviewer is not always feel that asked the question, feel is making things difficult for yourself? Obviously prepare their own knowledge are sufficient, why not ask their disposal? Xiao Bian here to tell you, you are missing the corresponding interview questions to guide, not a direction. Interview made rocket, entry tighten the screws, so that the interview for all of us is very important.

Xiao Bian we should consider, to share with Tsinghua University graduate Gangster collated Java network programming interview questions. Because the content is a bit more, small series here only to give you part of the screenshots out introduction, each section has a more detailed content.

First question to share Java network programming interview questions Daquan directory

Here Insert Picture Description

Secondly, it is to introduce a few small knowledge questions and answers

1, tcp and udp distinction
TCP: Transmission Control Protocol stream oriented connection, with high reliability, ensuring the correctness of data transmission, a verification retransmission mechanism, so there is no lost or scrambled.

UDP: connectionless datagram service, the data is not reported to be checked and modified, without waiting for the other's response, there will be packet loss, duplicate, out of order, but with better real-time, UDP segment structure than TCP segment structure simple, so the network overhead is small.

2, when the tcp connection establishment handshake 3, particularly 4-way handshake procedure disconnected

  1. 3-way handshake protocol to establish the connection used, in particular:

first handshake l connect a client to connect to server

L After the second server accept client requests, and sends a message to the client end, equivalent to saying that I was ready, you connect me

l third client is sent to the server, it is for second handshake acknowledgment message. After the client and server begin communicating.

2. Disconnect the 4-way handshake connection, as follows:

L end sends a close request to disconnect the first handshake

L needs to be performed after the other end close to the received connection confirmation request to disconnect, sends a message, which is the second handshake

L also transmitted after transmitting the acknowledgment message to the peer close message to close the connection to the terminal, this is the first 3-way handshake

l message is received after the end of the first transmission disconnected, into a state time_wait important state, which is often the interviewer asks the question, is the end of the last handshake originally transmitted the disconnect message is received after that. Acknowledgment of the message.
3. What is blocking IO? What is non-blocking IO?
Before looking at the blocking and non-blocking IO IO, next look at a specific process is how IO operations carried out.

Typically, the IO operations comprising: reading and writing to a hard disk, and read and write read and write socket peripherals.

When a user initiates a thread IO request operation (paper read request operation, for example), the kernel will go to see if the data is ready to be read, for blocking IO, if the data is not ready, we will have to wait on that until the data ready; for non-blocking IO, if the data is not ready, it will mark a return message to inform the user of the current thread to read the data is not ready. When the data is ready, put the data copied to the user thread, so to complete a full IO read request, and that means a complete IO read request operation consists of two phases:

1) Check whether the data is ready;

2) Data copying (copying of data to a user kernel thread).

So blocking (blocking IO) and the difference between non-blocking (non-blocking IO) is that the first stage, if the data is not ready, the process to see if the data is ready been waiting for, or directly return a flag information.

After the traditional Java IO IO are blocked, for example, to read the data through socket, calling read () method, if the data is not ready, the current thread will block until the read method calls there until there is data before returning;

And if it is non-blocking IO, so that when the data is not ready, read () method should return a flag information, inform the current thread data is not ready, and not have to wait there.

10. What is the internal structure of Nio buffer?

Here Insert Picture Description
15, the general network programming steps
for TCP connections:

1. The server
Here Insert Picture Description
32, briefly about the http protocol?
HTTP protocol is the Hyper Text Transfer abbreviation Protocol (Hypertext Transfer Protocol) is used from the World Wide Web (WWW: World Wide Web) server to transfer hypertext transfer protocol local browser.

HTTP is used to transfer a data (HTML files, image files, query results, etc.) based on TCP / IP communication protocol.

HTTP works

HTTP protocol works on the client - server architecture on. Browser as an HTTP client URL that is WEB server sends all requests to the server via HTTP.

There are Web servers: Apache server, Nginx, IIS server (Internet Information Services) and so on.

Web server according to the received request, transmits the response information to the client.

The default HTTP port number is 80, but you can also be changed to 8080 or other ports.

HTTP Three things to note:

l HTTP is a connectionless: Meaning No connection is to limit the processing only one request per connection. After the server processes client requests and receives the customer's response, i.e., disconnected. In this way it can save transmission time.

l HTTP Media Independence: this means that, as long as the client and the server knows how to handle the data content of any type of data can be sent via HTTP. The client and server specify the appropriate MIME-type content type.

l HTTP is stateless: HTTP protocol is stateless protocol. No state is no protocol for transaction processing and memory. If the lack of state means that the subsequent processing required in front of the information, it must be retransmitted, which may result in the amount of data transmitted for each connection is increased. On the other hand, when it does not require previous information in response to a faster server. Here Insert Picture Description
34, describe the http protocol response packet What?
HTTP response also consists of four parts, namely:

status line l

l message header

l empty line

l response bodyHere Insert Picture Description

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text/plain

Finally, sharing the Java network programming interview questions
Here Insert Picture Description
Here Insert Picture Description
because of space limitations, greatly accelerates here do not introduce too many friends.Here Insert Picture Description

Published 85 original articles · won praise 7 · views 20000 +

Guess you like

Origin blog.csdn.net/Ppikaqiu/article/details/104776493