In computer networking, a raw socket is an internet socket that allows direct sending and receiving of packets without any protocol-specific transport layer formatting.
In standard sockets, the payload is automatically encapsulated according to the chosen transport layer protocol (e.g. , ), and the socket-user is unaware of the existence of protocol headers that are broadcast with the payload. When reading from a raw socket, the headers are usually included. When transmitting packets from a raw socket, the automatic addition of a header is optional.
Raw sockets are used in security related applications like nmap. One possible use case for raw sockets is the implementation of new transport-layer protocols in user space. Raw sockets are typically available in network equipment, and used for such as the (IGMPv4) and Open Shortest Path First (OSPF), and in the (ICMP, best known for the ping suboperation) for example, sends ICMP echo requests and receives ICMP echo replies.
Most socket application programming interfaces (APIs), for example those based on Berkeley sockets, support raw sockets. Windows XP was released in 2001 with raw socket support implemented in the Winsock interface, but three years later, Microsoft limited Winsock's raw socket support because of security concerns.