Sample Programs
Connection Mode
exit(1);
} else {
/*
didn't get an ERROR_ACK either; print whatever primitive we did get
*/
printf(”error: expected primitive 0x%02x, ”, ex_prim);
printf(”got primitive 0x%02x\n”,
exit(1);
}
} else {
/* no control; did we get data? */ if(data_buf.len) {
/* tell user we only got data */ printf(”error: check_ctrl found only data\n”); exit(1);
} else {
/*
no message???; well, it was probably an interrupted system call
*/
printf(”error: check_ctrl found no message\n”); exit(1);
}
}
}
}
/************************************************************************** put a message consisting of only a data part on a stream
**************************************************************************/
void |
|
|
put_data(fd, length) |
| |
int | fd; | /* file descriptor */ |
int | length; | /* length of data message */ |
{ |
|
|
/* set the len field in the strbuf structure */ data_buf.len = length;
/* call putmsg and check for an error */ if(putmsg(fd, 0, &data_buf, 0) < 0) {
printf(”error: put_data putmsg failed, errno = %d\n”, errno); exit(1);
}
}
146 | Appendix A |