Sockets explained

They act as endpoints in a two-way communication channel.
For communication of two machines or applications each app/machine creates a socket.
Each socket is associated with IP and port. 

OSI
Sockets operate at layer 4 - transport layer.
Application layer calls down the socket api, for example browser, backend server etc

Types of Sockets:
- TCP(Transmission Control Protocol)
Connection oriented and responsible for ensuring reliable, ordered, error checked, non duplicate data transmission.
Before data is sent a three way handshake is performed to establish the connection.(exchange of SYN and ACK packets)
        - Client sends a SYN(synchronize) packet to initiate a connection.
        - SYN-ACK server responds with a SYN-ACK packet, acknowledging the receipt of SYN and sending its own SYN request.