ip(4p)ip(4p)Nameip - Internet Protocol
Syntax
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_RAW, 0);
Description
The IP is the transport layer protocol used by the Internet protocol
family. It can be accessed through a ``raw socket'' when developing
new protocols or special purpose applications. IP sockets are connec‐
tionless and are normally used with the and calls. The call, however,
can also be used to fix the destination for future packets, in which
case the or and or system calls can be used.
Outgoing packets automatically have an IP header prepended to them,
based on the destination address and the protocol number the socket is
created with. Incoming packets are received with their IP headers and
options intact.
Diagnostics
On failure, a socket operation returns any of the following errors:
[EISCONN] Tried to establish a connection on a socket that already
had one, or tried to send a datagram with the destina‐
tion address specified when the socket was already con‐
nected.
[ENOTCONN] Tried to send a datagram, but no destination address was
specified and the socket was not connected.
[ENOBUFS] The system ran out of memory for an internal data struc‐
ture.
[EADDRNOTAVAIL]
Made an attempt to create a socket with a network
address for which no network interface existed.
See Alsosend(2), recv(2), inet(4f), intro(4n), packetfilter(4)ip(4p)