TCP connection establishment

sponsored links
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
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of TCP connection establishment

  • Predictability (Prodictability) - Designed beauty

    Watched prison break, definitely designed by Scofield's admiration. Although during the prison break has a lot of accidents, but are at the basic design of Scofield, and these accidents also showed him the temporary ability to meet emergencies. F ...

  • Detailed Js Call Ways

    call method Please refer to Applies to: Function objects Request Version 5.5 An object calling a method to replace the current object to another object. call ([thisObj [, arg1 [, arg2 [, [,. argN ]]]]]) Parameters thisObj Optional. Will be used as the obj

  • DWR filters and exception handling

    Just modify dwr.xml: <dwr> <allow> <create javascript="UserService" creator="spring"> <param name="beanName" value="userService"> </ param> </ create> <! - Call UserService of

  • struts2 ajax verify the existence of input values

    struts2 ajax verify the existence of input values Today to do the struts2 ajax validate input regarding the existence of the function, and now share with everyone, I hope everyone many opinions!!! input.jsp page code: <html> <body> <s: ...

  • Ext2.2 + json + jsp questions to obtain background data - Ajax

    Ext-2.2 in the study, we will first study it usually comes with some examples, today found an example about paging, it is to use php access to json format data, And I found a lot of people online through java access to background data, so I wrote a jsp ac

  • Struts Spring Hibernate test Noodles

    Hibernate working principle and why to use? Principle: 1. To read and parse configuration file 2. Read and analytic mapping information, create a SessionFactory 3. Open Sesssion 4. Create Affairs transation 5. Persistence operation 6. Submitted Services 7

  • js examples of common events

    <html> <head> <script type="text/javascript"> / / Which mouse button is clicked function whichButton1 (event) ( if (event.button == 2) ( alert ( "You clicked the right mouse button!") ) else ( alert ( "You c ...

  • SUI-JavaScript rich UI library integration solution

    Introduction: SUI is not a class implementation of the UI, nor is it a standard set of UI markup language, it is just to help the existing UI frameworks (such as Ext, YUI like) to mark the way to the statement and the creation of UI. The names of these ta

  • How to do a good job in the demand for change management - needs to change flow specification

    Project Leader: assessment needs to change some of the workload to determine whether it needs to change the contents of the progress on the development of an impact, if the demand to change the progress of an impact on the development, the project le ...

  • hibernate using c3p0 connection pooling

    Private c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is v ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries