Read the man page.
For the prototype
int socket(int domain, int type, int protocol);
The types can be
SOCK_STREAM Provides sequenced, reliable, two-way, connection-
based byte streams. An out-of-band data transmission
mechanism may be supported.
or
SOCK_RAW Provides raw network protocol access.
In one line, SOCK_STREAM
is for connection oriented sockets, where the underlying OS creates and manages the headers for L4 (TCP), L3 and L2. OTOH SOCK_RAW
provides more fine-grained control over header and packet construction, where the user has to construct and supply the headers and can also manage the contents.
To elaborate:
Sockets of type SOCK_STREAM are full-duplex byte streams. They do
not preserve record boundaries. A stream socket must be in a
connected state before any data may be sent or received on it. A
connection to another socket is created with a connect(2) call. Once
connected, data may be transferred using read(2) and write(2) calls
or some variant of the send(2) and recv(2) calls. When a session has
been completed a close(2) may be performed. Out-of-band data may
also be transmitted as described in send(2) and received as described
in recv(2).
and
SOCK_RAW sockets allow sending of datagrams to
correspondents named in sendto(2) calls. Datagrams are generally
received with recvfrom(2), which returns the next datagram along with
the address of its sender.