Sample Programs
Connection Mode
/* Receive the 5 packets. */ for(i = 0; i < 5; i++) {
if(get_msg(recv_d_fd) != GOT_DATA) { printf(”error: didn't get data\n”); check_ctrl(0);
exit(1);
}
printf(”received %d bytes of data\n”, data_buf.len);
}
/*
We're finished. Now we tear down the connection. We'll send a DISCONNECT_REQ on the receiver side.
*/
disconnect_req(recv_d_fd);
/* and receive the DISCONNECT_IND on the sender side. */ get_msg(send_fd);
check_ctrl(DL_DISCONNECT_IND);
/* And finally, we tear down the sender and receiver streams */ cleanup(send_fd);
cleanup(recv_d_fd);
}
Appendix A | 155 |