TCP connections are basically established with the help of an exchange known as the three way handshake. In this if A is the client and B is the listening server at that time the process of handshake is proceeded. It is basically triggered by an application request which is being made to connect the data which is sent after the complete process of handshake.
A message sequence diagram uses vertical lines to represent events that happen at a computer over time (time is increasing as the line goes down). Addresses of the computers/software are given at the top of the vertical lines. Horizontal or sloped arrows are used to show messages (packets) being sent between computers. Each arrow should be labelled with the protocol, packet type and important information of the message.