What is a socket

Socket basically is a OS handle, but what does it represents?

 

First of all socket has properties like:

 

 

In our library we deal with IP, TCP, UDP, and ICMP sockets which can be regular or raw.

 

For each protocol a socket behaves differently:

 

IP

Can be used only for raw sockets, sending raw headers, not used for regular communication.

TCP

Has three parts:

 

  • Listener socket that waits for incoming connections.

  • Server's client socket that represents an incoming connection after it was accepted.

  • Socket that is used to connect to remote hosts.

 

For more information on TCP sockets see TCP sockets.

UDP

Since UDP is stateless it can both receive and send.

For more information see stateless sockets.

ICMP

Since ICMP is stateless it can both receive and send.

For more information see stateless sockets.