Socket: The instantiation of an end-point in a potential TCP connection
Instantiation: The actual implementation of something defined elsewhere
Port is more of a virtual descriptive thing. You’re only going to get a response if a program has opened a socket on that port.
TCP socket state
- LISTEN
- A TCP socket is ready and listening for incoming connections
- server-side only
- SYN_SENT
- A synchronization request has been sent, but the connection hasn’t been established yet
- client-side only
- SYN-RECEIVED
- A socket previously in a LISTEN state has received a synchronization request and sent a SYN/ACK back
- server-side only
- ESTABLISHED
- The TCP connection is in working order and both sides are free to send other data
- FIN_WAIT
- A FIN has been sent, but the corresponding ACK from the other end hasn’t been received yet
- CLOSE_WAIT
- The connection has been closed at the TCP layer, but that the application that opened the socket hasn’t released its hold on the socket yet
- CLOSED
- The connection has been fully terminated and that no further communication is possible
Socket state and their names can vary from one OS to OS. This is due to the fact that it resides out the scope of the TCP it self.