As we know TCP has 3-ways Handshake in simplest form. Here we look at situation, what would happen if both Hosts initiates connection at the same time. Below given images depicts exact situation and behavior of Hosts.
|Simultaneous Open TCP Connections|
For depth knowledge it is suggested to go back to TCP Connection Establishment. Lets see what happens exactly. Here both hosts act as a CLIENT and SERVER at same time. 4 messages are exchanged to be in established state rather than 3.
a) Both Hosts initiate SYN message to each other at same instance and goes in SYN-SENT state.
b) Now both also receives SYN message sent by other host and goes in SYN-RECEIVED from SYN-SENT. SYN-RECEIVED is only valid state in which a host can go.
c)Both Hosts replies with acknowledgment of received SYN as SYN-ACK with own sequence number and valid acknowledgement number as shown above.
d)Now both nodes receives SYN-ACK message with Sequence Number received in SYN message and Acknowledgement Number set to valid value. Implies message sent in previous state is reached to remote host. So ESTABLISHED is only valid state to go. Only one connection shall establish instead of two.
NOTE:- There is some error in RFC-793 figure-8 displaying simultaneous open TCP connection. Same can be confirmed from RFC-1122 section 188.8.131.52 Simultaneous Open Attempts.
Your Comments /Suggestions and Questions are always welcome. We would try to clarify doubts with best of our knowledge. So feel free to put Questions.