Selecting specific protocols
If the third argument to the
call is 0,
will select a default protocol to use with
the returned socket of the type requested.
The default protocol is usually correct, and alternate choices are not
However, when using ``raw'' sockets to communicate directly with
lower-level protocols or hardware interfaces,
the protocol argument may be important for setting up demultiplexing.
For example, raw sockets in the Internet domain may be used to implement
a new protocol above IP, and the socket will receive packets
only for the protocol specified.
To obtain a particular protocol, determine the protocol number
defined within the protocol domain.
For the Internet domain, use one of the library routines
such as getprotobyname (discussed in
pp = getprotobyname("newtcp");
s = socket(AF_INET, SOCK_STREAM, pp->p_proto);
This would result in a socket
using a stream
based connection, but with protocol type of
instead of the default
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005