UNIX Network Programming Reading Notes: Basic SCTP Interface Programming

Source: Internet
Author: User

Sctp_bindx (sockfd, sockaddr * addrs, addrcnt, -- success, --- Error

Sockfd is the set of interface descriptions returned by the socket function.

Addrs is a pointer to a compact address list. Each set of interface address structure follows the previous set of interface address structure, and no Bytes are filled in the middle. As shown in:

Flags Description SCTP_BINDX_ADD_ADDR
SCTP_BINDX_REM_ADDR Add the address to the socket Port
Remove address from socket Port

Sctp_bindx can be used for both bound and unbound APIs.

For unbound sets of interfaces, sctp_bindx binds the given address set to it. If SCTP_BINDX_ADD_ADDR is specified for a bound set of interfaces, the additional address is added to the set of Interface Description words, if SCTP_BINDX_REM_ADDR is specified, the specified address is removed from the added address of the Set interface description.

If sctp_bindx is called on a listening set interface, the new address configuration will be used for future associations; Existing associations will not be affected.

The two flags passed to sctp_bindx are mutually exclusive. If both flags are specified, the call fails and the error code EINVAL is returned.

The port numbers of all the interface address structures must be the same and must match the bound port number; otherwise, the call will fail and the EINVAL error code will be returned.

Sctp_connectx (sockfd, sockaddr * addrs, -- success, --- Error

The sctp_connectx function is used to connect to a multi-host peer host. This function specifies the addrcnt addresses in the addrs parameter that all belong to the same peer end. The addrs parameter is a compact address list. The SCTP stack uses one or more addresses to establish an association. All the addresses listed in the addrs parameter are considered valid and verified addresses.

Sctp_getpaddrs (sockfd, sctp_assoc_t id, sockaddr ** --- Error

The sockfd parameter is the set of interface descriptions returned by the socket function.

The id parameter is its associated identifier for one-to-many interfaces, and is ignored for one-to-one interfaces.

The addrs parameter is an address pointer, and the address content is a compact address list dynamically allocated and filled in by this function. After use, the caller uses sctp_freepaddrs to release the allocated resources.

Sctp_freepaddrs (sockaddr ** addrs );

The addrs parameter is a pointer to the address array returned by sctp_getpaddrs.

Sctp_getladdrs (sockfd, sctp_assoc_t id, sockaddr ** --- Error

The sockfd parameter is the set of interface descriptions returned by the socket function.

The id parameter is its associated identifier for one-to-many interfaces, and is ignored for one-to-one interfaces.

The addrs parameter is an address pointer, and the address content is a compact address list dynamically allocated and filled in by this function. After use, the caller uses sctp_freeladdrs to release the allocated resources.

Sctp_freeladdrs (sockaddr ** addrs );

The addrs parameter is a pointer to the address array returned by sctp_getladdrs.

Sockfd, * sockaddr * --- Error

The sockfd parameter is the set of interface descriptions returned by the socket function.

The msg parameter points to a buffer with msgsz byte length, and the content is sent to the peer vertex. The tolen parameter specifies the address length stored in.

The ppid parameter specifies the Net Load protocol identifier that will be passed along with the data block.

The flags parameter is passed to the SCTP stack to identify any SCTP options.

The caller specifies a SCTP stream number in the stream parameter.

The caller can specify the message life cycle in milliseconds in the timetolive parameter. 0 indicates an infinite life cycle.

The context parameter is used to specify possible user contexts.

Sockfd, * sockaddr *, socklen_t * sctp_sndrcvinfo * sinfo, * --- Error

Note: If the application process wants to receive sctp_sndrcvinfo information, you must use the SCTP_EVENTS interface option to reserve sctp_data_io_event (enabled by default ).

When this function is returned, the buffer indicated by the msg parameter is filled with data of up to msgsz bytes. The address of the message sender is stored in the from parameter, and the address structure is stored in the fromlen parameter. The msg_flags parameter stores possible message flags. Note: If the implementation maps sctp_recvmsg to the recvmsg function, the flags parameter of recvmsg is set to 0.

Sctp_opt_info (sockfd, sctp_assoc_t assoc_id, * arg, socklen_t * -- success, --- Error

The sockfd parameter provides the set Interface Description for obtaining the options of the preceding interface.

The assoc_id parameter provides possible association IDs.

The opt parameter is the set interface option of SCTP.

Arg provides a set of interface option parameters.

Siz is a socklen_t pointer used to store the parameter size.

Sctp_peeloff (--- Error

The syntax is similar to the accept function with an additional parameter. The caller passes the sockfd of the one-to-multi-mode interface and the id of the Association id to be extracted to the function call. At the end of the call, a new set of interface description is returned, which is a one-to-one set of interface descriptions associated with the request.

Notification

SCTP provides multiple types of notifications available for applications. SCTP users can track related statuses through these notifications. The notification transmits transmission-level events, including network status changes, associated startup, remote operation errors, and undeliverable messages. By default, all events except sctp_data_io_event are disabled.

You can use the SCTP_EVENTS interface to reserve 8 events. Seven events generate additional data called notification. The notification itself can be obtained through common set of Interface Description words. When the events that generate them occur, these notifications are embedded with the set interface description in the data. When a set of interfaces is read while the corresponding notifications are reserved, user data and notifications are staggered in the Set Interface Buffer. To differentiate the data from the peer end and the notifications generated by events, you should use the recvmsg function or the sctp_recvmsg function. If the returned data is an event notification, the msg_flags parameter returned by the two functions will contain the MSG_NOTIFICATION flag. This indicates that the message that the application process has just read is not from the peer data, but from the local SCTP stack.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.