HP Rp7410 HP DLPI Programmer's Guide - Page 190
result |= GOT_CTRL
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 190 highlights
Sample Programs Connection Mode Example 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) { result |= GOT_CTRL; } if(data_buf.len > 0) { result |= GOT_DATA; } return(result); } check that control message is the expected message 190 Appendix A