![]() |
![]() |
|
|
tprecv(3c)
Name
tprecv()—Routine for receiving a message in a conversational connection.
Synopsis
#include <atmi.h>
int tprecv(int cd, char **data, long *len, long flags, long \
*revent)
Description
tprecv() is used to receive data sent across an open connection from another program. tprecv()'s first argument, cd, specifies on which open connection to receive data. cd is a descriptor returned from either tpconnect() or the TPSVCINFO parameter to the service. The second argument, data, is the address of a pointer to a buffer previously allocated by tpalloc().
data must be the address of a pointer to a buffer previously allocated by tpalloc() and len should point to a long that tprecv() sets to the amount of data successfully received. Upon successful return, *data points to a buffer containing the reply and *len contains the size of the buffer. FML and FML32 buffers often assume a minimum size of 4096 bytes; if the reply is larger than 4096 bytes, the size of the buffer is increased to a size large enough to accommodate the data being returned.
Buffers on the sending side that may be only partially filled (for example, FML or STRING buffers) will have only the amount that is used sent. The system may then enlarge the received data size by some arbitrary amount. This means that the receiver may receive a buffer that is smaller than what was originally allocated by the sender, yet larger than the data that was sent.
The receive buffer may grow, or it may shrink, and its address almost invariably changes, as the system swaps buffers around internally. To determine whether (and how much) a reply buffer changed in size, compare its total size before tprecv() was issued with *len. See "Introduction to the C Language Application-to-Transaction Monitor Interface" for more information about buffer management.
If *len is 0, then no data was received and neither *data nor the buffer it points to were modified. It is an error for data, *data or len to be NULL.
tprecv() can be issued only by the program that does not have control of the connection.
The following is a list of valid flags:
If an event exists for the descriptor, cd, then tprecv() will return setting tperrno() to TPEEVENT. The event type is returned in revent. Data can be received along with the TPEV_SVCSUCC, TPEV_SVCFAIL, and TPEV_SENDONLY events. Valid events for tprecv() are as follows:
In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tprecv().
Return Values
Upon return from tprecv() where revent is set to either TPEV_SVCSUCC or TPEV_SVCFAIL, the tpurcode global contains an application defined value that was sent as part of tpreturn().
Upon failure, tprecv() returns -1 and sets tperrno() to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
Upon failure, tprecv() sets tperrno to one of the following values:
Usage
A server can pass an application defined return value and typed buffer when calling tpreturn(). The return value is available in the global variable tpurcode and the buffer is available in data.
See Also
tpalloc(3c), tpconnect(3c), tpdiscon(3c), tperrordetail(3c), tpsend(3c), tpservice(3c), tpstrerrordetail(3c)
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|