Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
SCTP Programmer's Guide: HP-UX 11i v2, HP-UX 11i v3 > Chapter 2 SCTP Socket APIs

API Options to Modify Socket Behavior

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

This section describes the APIs that include options to modify the socket behavior.

SCTP provides many socket options to modify options that are associated with a socket. These socket options can enable or disable certain functions to facilitate applications to control the transport of data.

If you modify a socket option, you must specify the level to which the option belongs. The level indicates whether the option applies to the socket interface, or to a lower-level communications protocol interface, such as IP, TCP, or SCTP.

You can use the getsockopt()() and setsockopt()() system calls to modify the socket options. These system calls set or retrieve socket interface options, or lower-level protocol options.

Following is the syntax for the getsockopt()() system call:

int getsockopt(
 int s,
 int level,
 int optname,
 void *optval,
 int *optlen
);

where:

s

Indicates the file descriptor.

level

Specifies the type of protocol. You must set the level to IPPROTO_SCTP for all the SCTP options.

optname

Specifies the option name.

optval

Specifies the buffer to store the value of the option.

optlen

Specifies the size of the buffer (or the length of the option returned).

Following is the syntax for the setsockopt()() API:

int setsockopt(
 int s,
 int level,
 int optname,
const void *optval,
 int optlen
 );

where:

s

Indicates the file descriptor.

level

Specifies the type of protocol. You must set the level to IPPROTO_SCTP for all SCTP options.

optname

Specifies the option name.

optval

Specifies the buffer to store the value of the option.

optlen

Specifies the size of the buffer (or the length of the option returned).

SCTP associations being multihomed, certain option parameters include the sockaddr_storage structure to select the peer address to which the option must be applied. For a one-to-many style socket, applications can use an association ID (sctp_assoc_t structure) to identify the association instance that is affected by the option. Applications must set this association ID while using a one-to-many API style socket. In the case of one-to-one style socket APIs and the branched off one-to-many style sockets, SCTP ignores this association ID parameter.

In the case of the one-to-many style APIs, the socket options are applied to all associations that belong to a socket. For a one-to-one API, the socket options apply to all peer addresses of the association controlled by the socket.

In the SCTP stack, the getsockopt()() is read-only. This means that applications cannot specify any information in the getsockopt()() call. As a result, applications must use the sctp_opt_info()() API to pass information both into and out of the SCTP stack.

Following is the syntax for the sctp_opt_info()() API:

int sctp_opt_info(int sd,
 sctp_assoc_t id,
 int opt,
 void *arg,
 socklen_t *size);

where:

id

Specifies the association ID. For a one-to-many style socket, id specifies the association to query. For a one-to-one style socket, SCTP ignores the ID.

opt

Specifies the SCTP socket option. The sctp_opt_info()() API retrieves socket options, specified as follows:

  • SCTP_RTOINFO

  • SCTP_ASSOCINFO

  • SCTP_DEFAULT_SEND_PARAM

  • SCTP_GET_PEER_ADDR_INFO

  • SCTP_PRIMARY_ADDR

  • SCTP_PEER_ADDR_PARAMS

  • SCTP_STATUS

sctp_opt_info()() does not support the authentication related-options SCTP_AUTH_CHUNKS, SCTP_AUTH_SECRET, and SCTP_PEER_AUTH_CHUNKS.

arg

Specifies an option-specific structure buffer that is provided by an application.

The sctp_opt_info()() API returns 0 on success, and returns -1 on failure. It sets errno to the appropriate error code.

The sctp_opt_info()() call is a replacement for getsockopt()(), and sctp_opt_info()() does not set any option associated with the specified socket. You must use the setsockopt()() call to set any writeable option, such as SO_LINGER and SCTP_NODELAY.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2007–2008 Hewlett-Packard Development Company, L.P.