Send a TDS packet to a server.
RETCODE dbsendpassthru(dbproc, send_bufp) DBPROCESS *dbproc; DBVOIDPTR send_bufp;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library/C uses to manage communications and data between the front end and the server.
A pointer to a buffer containing the TDS packet to be sent to the server. A packet has a default size of 512 bytes. This size may be changed using DBSETLPACKET.
DB_PASSTHRU_MORE, DB_PASSTHRU_EOM, or FAIL.
dbsendpassthru sends a TDS (Tabular Data Stream) packet to a server.
TDS is an application protocol used for the transfer of requests and request results between clients and servers. Under ordinary circumstances, a DB-Library/C application does not have to deal directly with TDS, because DB-Library/C manages the data stream.
dbrecvpassthru and dbsendpassthru are useful in gateway applications. When an application serves as the intermediary between two servers, it can use these routines to pass the TDS stream from one server to the other, eliminating the process of interpreting the information and re-encoding it.
dbsendpassthru sends a packet of bytes from the buffer to which send_bufp points. Most commonly, send_bufp will be *recv_bufp as returned by dbrecvpassthru. send_bufp may also be the address of a user-allocated buffer containing the packet to be sent.
A packet has a default size of 512 bytes. An application can change its packet size using DBSETLPACKET. See the dbgetpacket and DBSETLPACKET reference pages.
dbsendpassthru returns DB_PASSTHRU_EOM if the TDS packet in the buffer is marked as EOM (End Of Message). If the TDS packet is not the last in the stream, dbsendpassthru returns DB_PASSTHRU_MORE.
A DBPROCESS connection that is used for a dbsendpassthru operation cannot be used for any other DB-Library/C function until DB_PASSTHRU_EOM is received.
This is a code fragment using dbsendpassthru:
/*
** The following code fragment illustrates the
** use of dbsendpassthru() in an Open Server
** gateway application. It will continually get
** packets from a client, and pass them through
** to the remote server.
**
** The routine srv_recvpassthru() is the Open
** Server counterpart required to complete this
** passthru operation.
*/
DBPROCESS *dbproc;
SRV_PROC *srvproc;
int ret;
BYTE *packet;
while(1)
{
ret = srv_recvpassthru(srvproc, &packet,
(int *)NULL);
if( ret == SRV_S_PASSTHRU_FAIL )
{
fprintf(stderr, "ERROR - \
srv_recvpassthru failed in \
lang_execute.\n");
exit();
}
/*
** Now send the packet to the remote server
*/
if( dbsendpassthru(dbproc, packet) == FAIL )
{
fprintf(stderr, "ERROR - dbsendpassthru\
failed in lang_execute.\n");
exit();
}
/*
** We’ve sent the packet, so let’s see if
** there’s any more.
*/
if( ret == SRV_S_PASSTHRU_MORE )
continue;
else
break;
}