Message commands

Message commands can be used with custom Open Server applications. Adaptive Server does not support message commands. From the client-application programmer’s perspective, a message command is equivalent to an RPC command that is called by number rather than by name.

Your application initiates a message command by calling ct_command with type as CS_MESSAGE_CMD and *buffer as the address of a CS_INT variable that contains the identifier for the message command. For example:

CS_INT msg_id; if (ct_command(cmd, CS_MSG_CMD, (CS_VOID *)&msg_id, CS_UNUSED, CS_UNUSED) != CS_SUCCEED) { fprintf(stderr, "ftclient: ct_command(MSG_CMD) failed.\n"); return CS_FAIL; }

Message identifiers must be known to both the client application and the Open Server application. Typically, the message command identifiers that a server responds to are defined in a shared header file. Sybase reserves message identifiers in the range CS_USER_MSGID to CS_USER_MAX_MSGID (inclusive) for customer use.

Message commands can take parameters. These are supplied with ct_param or ct_setparam. Whether parameters are passed by name or by position depends on how the Open Server application is coded.

Code your application to handle the results of a message command with a standard results loop, as discussed in “Structure of the basic loop”. Among other result types, message commands can return message results (result type of CS_MSG_RESULT). See “Processing message results” for more information.