int bufid = pvm_initsend( int encoding ) call pvmfinitsend( encoding, bufid )
If the user is using only a single send buffer (and this is the typical case) then pvm_initsend() is the only required buffer routine. It is called before packing a new message into the buffer. The routine pvm_initsend clears the send buffer and creates a new one for packing a new message. The encoding scheme used for this packing is set by encoding. The new buffer identifier is returned in bufid.
The encoding options are as follows:
The following message buffer routines are required only if the user wishes to manage multiple message buffers inside an application. Multiple message buffers are not required for most message passing between processes. In PVM 3 there is one active send buffer and one active receive buffer per process at any given moment. The developer may create any number of message buffers and switch between them for the packing and sending of data. The packing, sending, receiving, and unpacking routines affect only the active buffers.
int bufid = pvm_mkbuf( int encoding ) call pvmfmkbuf( encoding, bufid )
The routine pvm_mkbuf creates a new empty send buffer and specifies the encoding method used for packing messages. It returns a buffer identifier bufid.
int info = pvm_freebuf( int bufid ) call pvmffreebuf( bufid, info )
The routine pvm_freebuf() disposes of the buffer with identifier bufid. This should be done after a message has been sent and is no longer needed. Call pvm_mkbuf() to create a buffer for a new message if required. Neither of these calls is required when using pvm_initsend(), which performs these functions for the user.
int bufid = pvm_getsbuf( void ) call pvmfgetsbuf( bufid ) int bufid = pvm_getrbuf( void ) call pvmfgetrbuf( bufid )
pvm_getsbuf() returns the active send buffer identifier. pvm_getrbuf() returns the active receive buffer identifier.
int oldbuf = pvm_setsbuf( int bufid ) call pvmfsetrbuf( bufid, oldbuf ) int oldbuf = pvm_setrbuf( int bufid ) call pvmfsetrbuf( bufid, oldbuf )
These routines set the active send (or receive) buffer to bufid, save the state of the previous buffer, and return the previous active buffer identifier oldbuf.
If bufid is set to 0 in pvm_setsbuf() or pvm_setrbuf(), then the present buffer is saved and there is no active buffer. This feature can be used to save the present state of an application's messages so that a math library or graphical interface which also uses PVM messages will not interfere with the state of the application's buffers. After they complete, the application's buffers can be reset to active.
It is possible to forward messages without repacking them by using the message buffer routines. This is illustrated by the following fragment.
bufid = pvm_recv( src, tag ); oldid = pvm_setsbuf( bufid ); info = pvm_send( dst, tag ); info = pvm_freebuf( oldid );