HP Rp7410 HP DLPI Programmer's Guide - Page 211
send i+1*10 data bytes with the first byte = i, data_area[0] =
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 211 highlights
Sample Programs Connectionless Mode Example /* First, we must open the DLPI device file, /dev/dlpi, and attach to a PPA. attach() will open /dev/dlpi, find the first PPA with the DL_HP_PPA_INFO primitive, and attach to that PPA. attach() returns the file descriptor for the stream. Here we do an attach for each file descriptor. */ send_fd = attach(); recv_fd = attach(); /* Now we have to bind to a IEEESAP. We will ask for connectionless data link service with the DL_CLDLS service mode. Since we are connectionless, we will not have any incoming connections so we set max_conind to 0. bind() will return our local DLSAP and its length in the last two arguments we pass to it. */ bind(send_fd, SEND_SAP, 0, DL_CLDLS, sdlsap, &sdlsap_len); bind(recv_fd, RECV_SAP, 0, DL_CLDLS, rdlsap, &rdlsap_len); /* print the DLSAPs we got back from the binds */ print_dlsap("sending DLSAP = ", sdlsap, sdlsap_len); print_dlsap("receiving DLSAP = ", rdlsap, rdlsap_len); /* Time to send some data. We'll send 5 data packets in sequence. */ for(i = 0; i < 5; i++) { /* send (i+1)*10 data bytes with the first byte = i */ data_area[0] = i; /* Initialize data area */ for (j = 1; j < (i+1)*10; j++) data_area[j] = "a"; print_dlsap("sending data to ",rdlsap, rdlsap_len); send_data(send_fd, rdlsap, rdlsap_len, (i + 1) * 10); /* receive the data packet */ recv_len = recv_data(recv_fd); printf("received %d bytes, first word = %d\n", recv_len, data_area[0]); } /* We're finished with PART 1. then close the device file. */ Now call cleanup to unbind, then detach, Appendix A 211