TCP connection establishment

Open the TCP handshake is also known as 3-way handshake (3 - way handshake), because it usually consists of three messages: one from client to server connection requests, one from the server to the client's confirmation, and another from the customer confirmation message to the server side.

Socket constructor call with a client when the connection is established, the protocol associated with the relationship between events:

TCP connection establishment

The client receives the server side sent a confirmation message immediately that the connection has been successfully established.

The Internet is a best (best - effort) network, the client's initial message or a reply message server may be lost during transmission. For this reason, TCP protocol will increase the time intervals repeated several times to send handshake messages. If the TCP client after a period of time the server has not received the return message, timeout and give up the connection. In this case, the constructor will throw an IOException. Connection timeout is usually longer, so after a few minutes to Socket constructor will fail.

"SYN_SENT" is the first and second handshake messages between the professional name of the client state.

Client underlying data structure:

TCP connection establishment

Socket server starts:

TCP connection establishment

When a client connection request arrives, the connection will create a new socket data structure. According to the arrival of a new socket address to set the message grouping: grouping the target packet Internet address and port number (respectively wxyz and q) into the socket's local network address and port number also; group as the source address and port number (abcd: p) then become the socket of the remote Internet address and port number. Note: The new socket's local port number is always consistent with the ServerSocket port number. New state of the socket is set to indicate the "Connecting (Connecting)" (on the server side, jargon called SYN_RCVD), and add it to ServerSocket socket data structure associated with a socket connection is not completely list. Note: ServerSocket does not change their state, their information would not be any change in address.

In addition to creating a new data structure underlying socket, the server's TCP implementation but also to the client send back a TCP handshake to confirm information.

TCP connection establishment

In the receiver to the client sent the three-way handshake before the third message, the server does not think the TCP handshake message has been completed. Article 3 handshake after the arrival of the new status data structure is set to "ESTABLISHED", and move it to another ServerSocket socket data structure, data structures associated with the list, the list can be represented by the ServerSocket's accept ( ) methods to receive the connection was successful. (If the first three handshake message receiver fails, the final will be "Connecting" state of the data structure to delete.)

Server program calls the ServerSocket's accept () method, as long as the socket data structure associated with the list of the arrival of new connection, the method calls to stop blocking. (Note that the call to accept () method, this list may have non-empty state.) At this point, a new connection is removed from the list data structure, and create a Sokcet instance, as the accept () method returns value.

TCP connection establishment

分类:Internet 时间:2011-09-16 人气:248
blog comments powered by Disqus


  • Data source rejected establishment of connection, message from server: "Host 'host 2010-07-05

    Data source rejected establishment of connection, message from server: "Host 'host name' is not allowed to connect to this MySQL server This is when the remote connection MySql Error! With localhost not reported exception, replaced by IP address will

  • Step one step, record a short message queue project lean Address 2010-04-15

    [Author of the article: Zhang Yan This version: v1.0 Last modified: 2010.03.18 reproduced please specify text links: ] HTTPSQS (HTTP Simple Queue Service) is a based on HTTP GET / POST protocols lightweight open sour

  • MMS Protocol Study Notes 2010-03-29

    MMS Protocol Study Notes What is the MMS MMS is the Multimedia Messaging Service (Multimedia Messaging Service) is an abbreviation, the Chinese translated as "MMS", can be used to send text, pictures, animation, audio and video multimedia inform

  • Call webservice connection timeout setting 2010-04-01

    webservice request time is 100 seconds by default the client when calling the data overload often Connection timed out ProductWs ps = new ProductWs(); ps.Timeout = 10 * 60 * 1000; // The connection timeout to 10 minutes If you want to set up unlimite

  • apache cxf-line reading ( 2010-04-11

    Apache CXF Apache CXF Documentation> Index> RESTful Services> JAX-RS Download | Documentation Overview How-Tos Frontends DataBindings Transports Configuration Debugging and Logging Tools RESTful Services WSDL Bindings Service Routing Dynamic Lang

  • Tomcat source code --- request processing (receiving, thread allocation) 1 2010-03-24

    First, in the above article has been completed to start tomcat, and then to do is to request and response messages The following is a tomcat in a document Xiangjie -------------------------------------------------- -----------------------------------

  • Based on the UDP and TCP Socket Programming Introduction 2010-07-15

    Trackback URI I. Introduction TCP (Transmission Control Protocol) and UDP (User Datagram Protocol is a network architecture, TCP / IP transport layer a layer of two different commu

  • TCP / IP communication and UDP communication is the difference? 2010-10-06

    TCP / IP communication and the difference between UDP traffic to phone calls and send text messages just as we distinguish between when we called each other to establish a connection first and only began to speak, that is, send data, and send text me

  • android http post request protocol method 2011-01-11

    One way: HttpPost (import org.apache.http.client.methods.HttpPost Code is as follows : private Button button1,button2,button3; private TextView textView1; button1.setOnClickListener(new Button.OnClickListener(){ @Override public void onClick(View arg

  • a complete list of http return status 2010-06-04

    Transfer from: http return status is that when a user tries to http or file transfer protocol (ftp) visit to the site server to issue a request, the server returns a status of the request, said the number of code. The state

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.037 (s). 13 q(s)