ACC X.25 Protocol User's Guide
X.25 Application Programming
Sending and Receiving Data
Chapter 4 75
#include <zcom/zcomsys.h>
#include <zcom/zcomx25.h>
int rc; /* General return code. */
int rlen; /* # of bytes returned in rdata. */
unsigned char rdata[1204]; /* Buffer for inbound data. */
zmhd_type msghdr; /* ZCOM Message header structure. */
zaddr_type l3zlu; /* Our X.25 Virtual Circuit ZLU. */
zaddr_type pzlu; /* Our application’s program ZLU. */
/*
Issue a request to enable and activate the VC ZLU. Note: For the purposes
of this example, assume that l3zlu and pzlu have already been initialized.
*/
if (rc = zcntl(&l3zlu, 1, ZCOM_MRQCODE_ENB, 0, 0, 0)) {
/* Handle Error */
}
if (rc = zcntl(&l3zlu, 1, ZCOM_MRQCODE_ACT, 0, 0, 0)) {
/* Handle Error */
}
/*
Issue request to deliver inbound data and status to this application.
*/
if (rc = zset_rcvr(ZcADD_PRIMARY, &l3zlu, 0, &pzlu)) {
/* Handle Error */
}
while (1) /* Inifinite loop to read data */
{
if (rc = zread(&pzlu, 0, &msghdr, rdata, sizeof(rdata), &rlen, NULL)) {
/* Handle Error */
break;
}
l3zlu = msghdr.mid.mzsrce; /* ZLU of Virtual Circuit that data came from. */
switch (msghdr.mid.mstype)
{
case ZCOM_MSTYPE_MSLT: /* (1) Data from local VC ZLU (terminal) */
{ /* rdata[] contains data from remote end of VC. */
if (msghdr.mrq.mrqtag & 0x10) /* M-bit set ? */
{ /* Yes */
}
if (msghdr.mrq.mrqtag & 0x80) /* Q-bit set ? */
{ /* Yes */
}
break;
}










