| United States-English |
|
|
|
![]() |
SCTP Programmer's Guide: HP-UX 11i v2, HP-UX 11i v3 > Chapter 2 SCTP Socket APIsCommon Socket Calls |
|
This section discusses socket calls that are common to both one-to-one and one-to-many style APIs. Applications can use the send()() and sendto()() socket calls to transmit data to the peer. The recv()() and recvfrom()() socket calls can be used to receive data from the peer. Following are the syntaxes for the send()(), sendto()(), recv()(), and recvfrom()() socket calls, respectively:
where:
The send()(), sendto()(), recv()(), and recvfrom()() calls provide access to only basic SCTP protocol features. If a peer in an association uses multiple streams or sends unordered data, these calls may not be adequate. As a result, it may deliver data in unpredictable ways. These calls do not allow the application to specify the stream on which a message must be sent. SCTP uses stream 0 as the default stream to send data using send()() and sendto()(). The recv()() and recvfrom()() calls return data from any stream. However, the application cannot distinguish the different streams. As a result, data arrives without any order. Similarly, if an application sends unordered data chunk, recv()() and recvfrom()() do not provide any notification for the unordered data. The message buffer buf in the send()() and sendto()() calls is a single message buffer. If the caller wants to send a message that is composed of several buffers, the caller must combine all the buffers, before calling send()() and sendto()(). Alternately, the caller can use the sendmsg()() call to send multiple buffers, without combining the buffers. The recv()() and recvfrom()() calls cannot distinguish message boundaries. You cannot use the send()() and recv()() calls in the case of one-to-many style sockets.
Applications use the setsockopt()() and the getsockopt()() calls to set and retrieve socket options. You can use the socket options to modify the default behavior of the sockets calls. For information on socket options, see “API Options to Modify Socket Behavior”.
Following are the syntaxes for the getsockopt()() and setsockopt()() socket calls, respectively:
where:
Applications use read()() and write()() socket calls to send and receive data to and from a peer. These socket calls have the same functionality as the send()() and recv()() socket calls, except that the flags parameter is not present in the read()() and write()() calls. If these calls are used in one-to-many style sockets, applications can use these calls only with branched off socket descriptors. 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:
where:
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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||