HP rp7400 HP DLPI Programmer's Guide - Page 202
Sample Programs, then when he calls check_ctrl it will compare the expected primitive
View all HP rp7400 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 202 highlights
Sample Programs Connectionless Mode Example u_longctrl_area[LONG_AREA_SIZE];/* for control messages */ u_longdata_area[LONG_AREA_SIZE];/* for data messages */ struct strbuf ctrl_buf = { AREA_SIZE,/* maxlen = AREA_SIZE */ 0,/* len gets filled in for each message */ ctrl_area/* buf = control area */ }; struct strbuf data_buf = { AREA_SIZE,/* maxlen = AREA_SIZE */ 0,/* len gets filled in for each message */ data_area/* buf = data area */ }; get the next message from a stream; get_msg() returns one of the following defines define GOT_CTRL1/* message has only a control part */ #define GOT_DATA2/* message has only a data part */ #define GOT_BOTH3/* message has both control and data parts */ int get_msg(fd) intfd;/* file descriptor */ { intflags = 0;/* 0 ---> get any available message */ intresult = 0;/* return value */ /* zero first byte of control area so the caller can call check_ctrl without checking the get_msg return value; if there was only data in the message and the user was expecting control or control + data, then when he calls check_ctrl it will compare the expected primitive zero and print information about the primitive that it got. */ ctrl_area[0] = 0; /* call getmsg and check for an error */ if(getmsg(fd, &ctrl_buf, &data_buf, &flags) < 0) { printf("error: getmsg failed, errno = %d\n", errno); exit(1); } if(ctrl_buf.len > 0) { 202 Appendix A