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 人气:229
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

  • The unit does not install the Oracle client, use the PL / SQL Developer kit connection and Instant Client 2011-05-04

    1, the first site to download Oracle Instant Client: Depending on your operating system to select a different version of Instant Client Download back is a compresse

  • Open source software source code SVN Address _ 2010-05-02

    Spring3.0 https: / / / svn / spring-framework / Spring2.5 and the following version of https: / / / svn / spring-maintenance / Spring Security https: / / / svn / spring-security

  • The source code svn address kettle 2011-07-06

    Web addresses to start search svn: / / / svnkettleroot / Kettle / trunk Download speed is slower. Here the source is 3.X version. Another source to download at: ", the username is" ano

  • 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

  • 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 -------------------------------------------------- -----------------------------------

  • 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

  • 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

  • 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

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.537 (s). 10 q(s)