SNMP Manager Programmer's Guide
Sending and Receiving Packets
SNMP Manager Programmer’s Guide–134249
7-4
Sending Packets
After EBufferReset() reinitializes the ebuffp descriptors, a second descriptor structure, 
myEBuff, is initialized. Two sets of descriptors are needed because the buffers 
transmitted using the IPC protocol vary slightly from those using the UDP protocol. 
UDP buffers must contain at their start the target port and IP address: 
EBufferReset(ebuffp);
memcpy ((char*) &myEBuff, (void *) ebuffp, sizeof(myEBuff));
The packet passed in spkt is IPC-encoded into the buffer to which myEBuff points:
err = tdm_SNMP_Encode_Packet(spkt, &myEBuff, 
 host_int->local_flag);
Variables needed for the WRITEX() call are initialized, and sending the encoded packet 
to the agent is initiated using WRITEX(). FILE_GETINFO_() is called if WRITEX() 
initiation fails:
temp_file_num = host_int->file_num;
send_cnt = EBufferUsed(&myEbuff);
...
 status = WRITEX(host_int->file_num, myEBuff.start_bp,
 send_cnt, &written_cnt);
 if (status != CCE)
 {
 FILE_GETINFO_ (host_int->file_num, &err);
 host_int->err_num = err; /* Save the error number */
 if (PRINT_DEBUG_MSG)
 {
 fprintf(stdout, "WRITEX initialization failed with
 error %i.\n", err);
 }
 return WRITE_FAILED;
 }
The WRITEX() call writes data from the buffer to which myEBuff points, starting at the 
byte start_bp points to and continuing for the number of bytes indicated in send_cnt, to 
the NonStop agent process associated with the file number in file_num. The function 
returns the number of bytes sent in written_cnt.  If WRITEX() returns any value to status 
except CCE, which indicates success, FILE_GETINFO() returns a file system error 
number to the err variable characterizing the failure. 
A call to AWAITIOX() is made to complete the I/O operation initiated with WRITEX(). 
The file number for the NonStop agent connection and timeout value initialized at 
startup are input arguments:
AWAITIOX (&temp_file_num, (long *) &IOC_buffp, &written_cnt,
 &IO_tag, (long)(host_int->timeout));
After a period of time no greater than the number of centiseconds specified in timeout, 
AWAITIOX() returns the file number, the address of the buffer passed for the write 
operation, and the number of bytes written. The value of IO_tag is undefined because a 
tag was not supplied in the WRITEX() call. A call to FILE_GETINFO_() returns to err 
a file-system number characterizing the outcome of the write operation:
 FILE_GETINFO_ (host_int->file_num, &err);










