HPlogo X25/9000: X.25/9000 Programmer's Guide > Chapter 4  Sending and Receiving Data

Getting Next Message Status

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

You can use the ioctl(X25_NEXT_MSG_STAT) system call to obtain information about the next available message. ioctl(X25_NEXT_MSG_STAT) is almost always used when the ioctl(X25_SET_FRAGMENT_SIZE) is used. ioctl(X25_NEXT_MSG_STAT) returns the following information:

  • Size of the next message or next message fragment

  • Status of the MDTF, D or Q bits on the next message

  • If call user data is available on the next message

  • If clear data is available on the next message

  • If a connection is established on the VC

Syntax for ioctl(X25_NEXT_MSG_STAT)

The syntax for the ioctl(X25_NEXT_MSG_STAT) system call and its parameters are described below.

#include <x25/x25ioctls.h>
#include <x25/x25str.h>
/* struct x25_msg_stat {
* int x25_msg_size
* int x25_msg_flags;
* } x25_msg_stat;
*/
int err;

int sd;
struct x25_msg_stat status;
err = ioctl(sd, X25_NEXT_MSG_STAT, &status);

sd

A socket descriptor for an SVC socket.

X25_NEXT_MSG_STAT

Indicates that the status of the socket is being obtained.

status

Indicates the current status of the next message. If status.x25_msg_size is 0, there is no message in the queue; otherwise, it indicates the size of the next message or the next fragment of a message to be read. This is useful to ensure that there is enough buffer space for the next read system call. The status.x25_msg_flags field indicates whether the D or Q bits were set in the next message to be read. The status.x25_msg_flags field also indicates if the next fragment is the last fragment in the message.

The M bit was set in the last packet of the last message fragment read (this means that this is a continuation of the previous message fragment). The position of these bits in the field are indicated by the X25_MDTF_BIT, X25_D_BIT, and X25_Q_BIT definitions.

err

Upon successful completion, err is set to 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.