42.1 BSD Values

This section describes the values and flags used by the BSD functions:

42.1.1 Message Types

The following flags are used for sending and receiving messages and specify the type of message reception. They can be ORed together.

Flag

Value

Description

MSG_OOB

0x01

Process out-of-band data.

MSG_PEEK

0x02

Peek at incoming messages. The data is treated as unread and the next recv or similar function shall still return this data.

Used only by receive functions.

MSG_DONTROUTE

0x04

Do not route this data.

Used only by send functions.

42.1.2 IP Options

The following IP options can be returned and set with the getsockopt and setsockopt functions. The level must be set to IPPROTO_IP. The multicast related options for IPv6 are not currently supported.

Flag

Value

Description

IP_OPTIONS

1

Indicates IP header options in the options field of the IP header which are transmitted in each outgoing packet and are examined on incoming packets. For more information about the format, see RFC 791.

To disable previously specified options, use a zero-length buffer. For example:

  setsockopt( s, IPPROTO_IP, IP_OPTIONS, NULL, 0 )
  

Data type: unsigned char

IP_MULTICAST_IF

2

Specifies the IP multicast interface to use and permits the sending of multicast messages on the specified interface.

An address of INADDR_ANY (0x00000000) removes the previous selection of an interface.

Data type: in_addr structure

IP_MULTICAST_TTL

3

Indicates the multicast time-to-live for multicast packets. The value can be between 0 and 255.

Data type: unsigned char

IP_MULTICAST_LOOP

4

Indicates whether the multicast loopback is enabled, which allows the sending host to receive transmitted messages.

To enable loopback, set this option to 1; to disable, to 0. By default, loopback is enabled.

Data type: unsigned char

IP_ADD_MEMBERSHIP

5

Adds a multicast membership. This option can be used only with setsockopt.

Data type: ip_mreq structure

IP_DROP_MEMBERSHIP

6

Removes a multicast membership. This option can be used only with setsockopt.

Data type: ip_mreq structure

42.1.3 Socket Options

The following socket options can be returned and set with getsockopt and setsockopt functions. The level must be set to SOL_SOCKET. For boolean options, a zero value indicates that the option is disabled and a nonzero value indicates that the option is enabled.

Flag

Value

Description

SO_DEBUG

0x0001

Indicates whether debugging information is being recorded. This is a Boolean option which stores an int value in optval. This option has no effect on NetWare®.

SO_ACCEPTCONN

0x0002

Indicates whether socket listening is enabled. This is a Boolean option which stores an int value in optval.

SO_REUSEADDR

0x0004

Indicates whether the rules used in validating addresses supplied in bind should allow reuse of local addresses. This option is typically enabled only for TCP sockets that connect and use a fixed local port value, as in the File Transport Protocol (FTP).

This is a Boolean option which stores an int value in optval.

SO_KEEPALIVE

0x0008

Indicates whether connections are kept active with periodic transmission of messages on a connected socket. Should the connected party fail to respond to these messages, the connection is considered broken, and requests on the socket fail and return ETIMEDOUT.

By default this option is turned off (set to 0). To enable the timer, set this option to 1-4.

SO_DONTROUTE

0x0010

Indicates whether outgoing messages bypass the standard routing facilities. This is a Boolean option which stores an int value in optval. This option has no effect on NetWare.

SO_BROADCAST

0x0020

Indicates whether the transmission of broadcast messages is supported. This is a Boolean option which stores an int value in optval. This option has no effect on NetWare, because NetWare clients can always send broadcast packets.

SO_USELOOPBACK

0x0040

Indicates whether loop backs are allowed. This is a Boolean option which stores an int value in optval.

SO_LINGER

0x0080

Controls the action taken when unsent data is queued on a SOCK_STREAM socket and close is called. optval can point to a struct linger argument (defined in SYS/SOCKET.H) and specifies the desired state of the option and the linger interval.

If SO_LINGER is enabled and the linger time is nonzero, close blocks indefinitely (or until the protocol is able to deliver the data). If the linger time is zero, the protocol aborts the connection when close is called and can lose data. If SO_LINGER is disabled and close is called, the protocol assumes responsibility for delivering the data and permits the client to continue without blocking (which is the default behavior).

This option uses a linger structure to store a value in the optval parameter.

SO_OOBINLINE

0x0100

Requests that out-of-band data be placed in the normal data input queue as received. The data is then accessible by calling recv or read without the MSG_OOB flag.

This is a Boolean option which stores an int value in optval.

SO_SNDBUF

0x1001

Specifies the limit placed on output data buffering. The limit can be increased for high-volume connections or decreased to limit the possible backlog of buffered data. The system places an absolute limit of 64 KB on this value.

This option stores an int value in the optval parameter.

SO_RCVBUF

0x1002

Is the counterpart to SO_SNDBUF for incoming data. It determines the size of the TCP receive window. The sender and receiver should have similar send and recv buffer limits to be most efficient.

This option stores an int value in the optval parameter.

SO_SNDLOWAT

0x1003

Reports the minimum number of bytes to process for socket output operations. This option stores an int value in the optval parameter. This option has not been implemented on NetWare.

SO_RCVLOWAT

0x1004

Reports the minimum number of bytes to process for socket input operations. This option stores an int value in the optval parameter. This option has not been implemented on NetWare.

SO_SNDTIMEO

0x1005

Reports the timeout value that output functions can block because flow control prevents data from being sent. The default value for this option is 0, indicating that send functions do not time out.

This option uses a timeval structure to set a timeout value.

This option has not been implemented on NetWare.

SO_RCVTIMEO

0x1006

Reports the timeout value that input operations wait for an input operation to complete. The default value for this option is 0, indicating that receive functions do not time out.

This option uses a timeval structure to set a timeout value.

This option has not been implemented on NetWare.

SO_ERROR

0x1007

Returns any pending error code on the socket and clears the error status. You can use it to check errors on connected datagram sockets.

This option stores an int value in the optval parameter.

SO_TYPE

0x1008

Returns the type of the socket (see Socket Types). This option stores an int value in the optval parameter.

42.1.4 Socket Types

When you create a socket with the socket function, you can set it to one of the following types.

Flag

Value

Description

SOCK_NULL

0

Indicates that either SOCK_STREAM or SOCK_DGRAM is valid. You can also use 0 to indicate this.

SOCK_STREAM

1

Provides a sequenced, reliable, bidirectional, connection-mode stream socket.

SOCK_DGRAM

2

Provides a datagram socket.

SOCK_RAW

3

Provides a raw-protocol interface for ICMP.

SOCK_RDM

4

Provides for reliably-delivered messages. Not implemented on NetWare.

SOCK_SEQPACKET

5

Provides a sequenced, reliable, bidirectional, connection-mode for records. Not implemented on NetWare.

42.1.5 TCP Options

The following TCP option can be returned and set with the getsockopt and setsockopt functions. The level must be set to IPPROTO_TCP.

Flag

Value

Description

TCP_NODELAY

1

Indicates whether the Nagle delay algorithm is enabled. By default, this option is enabled. To disable it, set this option to 1.