You are here: SwitchKit Programmer’s Guide > 7 Message Functions > sk_rcvAndDispatchAutoStorage()
sk_rcvAndDispatchAutoStorage()
Description
The sk_rcvAndDispatchAutoStorage() is identical to sk_rcvAndDispatch(), except that instead of passing in a pre-allocated buffer, this function automatically allocates enough memory to receive whatever message comes from the switch. This message is also available as sk_rcvAndDispatchAutoStorageOnConnection() and skts_rcvAndDispatchAutoStorage().
int sk_rcvAndDispatchAutoStorage(char **aBufferPtr, int *aBufSize, double aTimeout, void **notCurrentlyUsed);
int sk_rcvAndDispatchAutoStorageOnConnection(char **aBufferPtr, int *aBufSize, double aTimeout, void **notCurrentlyUsed, int *aConIDPtr);
The function parameters are shown in the table below.
Argument |
Description |
---|---|
aBufferPtr |
Pointer to a packed message pointing to memory allocated and owned by SwitchKit API. Application wishing to retain this information beyond the next call to a SwitchKit API function should copy the data to memory allocated and controlled by the application as the memory may be reused the next time a SwitchKit API function is called. |
aBufSize |
Size of the packed message. |
aTimeout |
The maximum time the function should wait for a message before returning. The timeout value is a floating point number allow the application to specify a fractional portion to the timeout. For example, a timeout value of 1.5 seconds would be interpreted as a one and one-half second timeout. If no message arrives which is destined for the application in the specified time, the function should return SK_NO_MESSAGE. |
NotCurrentlyUsed |
The field is no longer used by the SwitchKit API and still exists for backward compatibility. This value should be set to NULL(0). |
aConIDPtr |
This is used to identify from which LLC connection the message was received. |
Important! The storage of this buffer is managed automatically by SwitchKit.
Possible return values for this function:
SK_LOST_LLC |
This return value indicates that your application lost contact with the LLC. |
SK_NO_MESSAGE |
No message was received. The time-out expired before a message was received or the LLC received a poll message from the switch. |
SK_BAD_MESSAGE |
An improperly formatted message was received |
SK_NOT_HANDLED |
Message was not handled by handler function, and no results are available. |