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().

Syntax

int sk_rcvAndDispatchAutoStorage(char **aBufferPtr, int *aBufSize, double aTimeout, void **notCurrentlyUsed);

int sk_rcvAndDispatchAutoStorageOnConnection(char **aBufferPtr, int *aBufSize, double aTimeout, void **notCurrentlyUsed, int *aConIDPtr);

Parameters

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.

Return Values

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.

SK_INVALID_LINK

A message was directed to a node that LLC was no longer connected to. This could happen when a connection to a node is unexpectedly severed.

SK_FRAMING_FAILURE

Message being sent to a node has a mismatched length between the actual length and the calculated length Reformat the message and send again.

SK_SOCKET_WRITE_FAILURE

LLC encountered an issue writing a message to a socket. This could be the result of a full socket (the distant end not reading from the socket appropriately) or a severed connection.

SK_NODE_NOT_FOUND

A message was directed to a node that LLC is not connected to. This could happen when an application specifies a node ID that has not been added to this configuration.