SCTP Programmer's Guide

The getsockname() Socket Call
Applications use getsockname() to retrieve the locally-bound socket address of the
specified socket. This is especially useful if the caller allows SCTP to select a local port.
The getsockname() API is also useful if an SCTP endpoint is not multihomed. An
HP-UX socket uses its copy of the bound address to implement the getsockname()
system call.
Following is the syntax for the getsockname() socket call:
int getsockname(int sd, struct sockaddr *address,
socklen_t *len);
where:
sd
Specifies the socket descriptor to be queried.
address
Stores the locally bound address that is selected by the SCTP stack. If the
socket is an IPv4 socket, the address will be an IPv4 address. If the socket
is an IPv6 socket, the address can be either an IPv6 or IPv4 address.
len
Specifies the length of the address.
If the actual length of the address is greater than the length of the sockaddr structure,
the stored address is truncated. If the socket is not bound to a local name, the value
contained in the address variable is not specified.
SCTP Events and Notifications
An event refers to a change in the network status, association startups, remote
operational errors, or undeliverable messages. An SCTP application must understand
and process these events, and resolve errors that occur on an SCTP stack.
If an SCTP application wants the SCTP stack to deliver notifications for a particular
event, the SCTP application can set the appropriate socket option for notifications in
the setsockopt() call. You can configure an SCTP application to send notifications
using the setsockoptg() call. When an SCTP application sends a recvmsg() call
to another application at the peer endpoint, the SCTP application normally reads the
data message from the peer endpoint. For information on recvmsg(), see “The
sendmsg() and recvmsg() Socket APIs” (page 47).
If the SCTP application reads a non-data message, the application sets the message
notification flag in the recvmsg() API. When the notification arrives, recvmsg()
returns the notification in the application-supplied data buffer in the msg_iov parameter,
and sets the MSG_NOTIFICATION flag in the msg_flags parameter. A recvmsg()
call returns only one notification at a time. While the SCTP application is reading data,
recvmsg() returns a part of a notification if the msg_iov buffer is not sufficient. If a
single read is not sufficient, MSG_EOR is not set in the msg_flags parameter. The SCTP
application must finish reading the notification before the subsequent data arrives.
Following is the SCTP notification structure:
SCTP Events and Notifications 57