![]() |
![]() |
|
|
![]() |
![]() |
X25/9000: X.25/9000 Programmer's Guide > Chapter 4 Sending and Receiving
Data![]() Setting Buffer Thresholds and Sizes |
|
X.25 allows programmers to fine-tune socket behavior by specifying certain characteristics such as when a socket (is writable) allows information to be written to its buffers. This is accomplished by setting the threshold values that control the size of the three socket buffers: outbound message, send, and receive. The write buffer threshold is used to determine if there is enough buffer space available to send another message without blocking the socket. If the buffer space available is greater than or equal to the write threshold, the socket will indicate writable when a select() call is issued. The ioctl(X25_WR_WTHRESHOLD) call is used to set the write threshold value. The value specified with ioctl(X25_WR_THRESHOLD) effects send(), write(), and select(). Whenever a send() or a write() call are issued, the amount of space remaining in the send socket buffer is checked; the amount of data in the outbound queue is subtracted from the size of the send socket's buffer. This check is performed in terms of network memory units and so is subject to round-off error. If this remaining space is insufficient to accept another message of the write threshold size, the free space size for the send socket is forced to zero, and remains that way until enough data is moved to the X.25 interface. If another send() or write() call is issued during this time, the call is blocked (for nonblocking I/O, EWOULDBLOCK is returned). The ioctl(X25_WR_WTHRESHOLD) call and its parameters are described below. The syntax for the ioctl(X25_WR_WTHRESHOLD) system call and its parameters are described below.
sdA socket descriptor for an SVC socket. X25_WR_WTHRESHOLDIndicates that the write threshold is being changed. threshIndicates the new value for the write threshold. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. X.25 assumes that all VCs will read whole messages with a single read() or recv() system call. This is usually the most efficient use of the VC. A message is a set of packets that all have their M bits set to 1 (except the last packet). Connections over most VCs do not use extremely long messages, and the maximum size of a read() or recv() buffer is usually sufficiently large. However, if at any time during the connection the application anticipates that the VC will receive messages longer than the maximum read() or recv() buffer size, it must set the read message fragment size to a value greater than 0. The read() and recv() calls return a whole number of packets, even when a message fragment is being read. This may cause the message fragment being read to be slightly longer or shorter than the fragment size specified in the ioctl(X25_SET_FRAGMENT_SIZE) system call. The ioctl(X25_NEXT_MSG_STAT) call is used to indicate the necessary buffer size in all instances. When reading a long message requiring several read() or recv() calls, you must use the ioctl(X25_NEXT_MSG_STAT) call to detect the end of the message. When this call returns the x25_msg_flags value with the X25_MDTF_BIT set to 0, the next read() or recv() system call will return the end of the message. To avoid data collision problems the ioctl(X25_SET_FRAGMENT_SIZE) call should be issued before the connect() call or between the accept() and the ioctl(X25_SEND_CALL_ACEPT) calls. The ioctl(X25_SET_FRAGMENT_SIZE) call and its parameters are described below. The syntax for the ioctl(X25_SET_FRAGMENT_SIZE) system call and its parameters are described below.
sdA socket descriptor for a VC socket. X25_SET_FRAGMENT_SIZEIndicates that the inbound message fragment size is being changed. sizeIndicates the new value for the read fragment size of messages. The range is from 0 to 32,767 where 0 indicates that all messages must be read with a single system call. errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. You can set the message sizes for a socket using the setsockopt(2) system call. It is important for the sockets to be able to handle the largest possible message that will be sent or received over the network. The default send and receive buffer size is 4096 bytes. If your interface receives a message larger than the receive socket buffer size, the data will be discarded, the circuit will be reset, and you will receive an OOB_VC_MSG_TOO_BIG out-of-band event. You can increase the size of a socket's send() or recv() buffer at any time, but they can only be reduced before a connection is established. The syntax for the setsockopt() system call and its parameters are described below.
sdA socket descriptor for an SVC socket. levelIndicates the level at which the socket takes effect. The definition SOL_SOCKET should be specified. optnameIndicates the type of option to be modified. This can be SO_SNDBUF to change the size of the send buffer or SO_RCVBUF to change the size of the receive buffer. optvalIndicates the new send or receive buffer sizes where the maximum size is 58,254. optlenIndicates the length in bytes of the optval parameter; that is, sizeof(int). errUpon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. Increasing the send socket buffet size allows a user to send more data before the user's application blocks, waiting for more buffer space. If more than one message cannot be sent without the user waiting for a reply, the programmer may want to increase the send buffer size to allow enough room to send multiple messages.
Refer to the setsockopt(2) entry in your HP-UX man pages for more information. |
![]() |
||
![]() |
![]() |
![]() |
|||||||||
|