C Client API

powerful. fast. easy.

Your C applications require the utmost in performance and reliability. Use the AMPS C/C++ Client to handcraft applications and libraries in C with blistering performance and rock-solid reliability. The AMPS C/C++ Client allows you to call the same low-level AMPS primitives used by our C++ client. Here's an example to get you started:

Example 1: Connect and Subscribe

Allocate and connect an AMPS client handle with just a few function calls:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <amps.h>
#include <stdio.h>
     void displayError(amps_handle client)
     {
       char textBuffer[512];
       amps_client_get_error(client, textBuffer, sizeof(textBuffer));
       printf("error from AMPS: %s\n", textBuffer);
     }
 
     amps_result receiveMessage(amps_handle message, void* userdata)
     {
       amps_char* data;
       size_t len;
       amps_message_get_data(message, &data, &len);
       fwrite(data, 1, len, stdout);
       fwrite("\n", 1, 1, stdout);
       return AMPS_E_OK;
     }
 
     int main()
     {
       amps_handle client, m;
       const char* uri="tcp://localhost:9004/nvfix";
 
       client = amps_client_create("myApp");
       if(amps_client_connect(client, uri) != AMPS_E_OK) {
         displayError(client);
         return -1;
       }
       m = amps_message_create(client);
       amps_message_set_field_value_nts(m, AMPS_QueryID, "1");
       amps_message_set_field_value_nts(m, AMPS_CommandId, "1");
       amps_message_set_field_value_nts(m, AMPS_Command,
         "subscribe");
       amps_message_set_field_value_nts(m, AMPS_Topic, "orders");
       amps_message_set_field_value_nts(m, AMPS_Filter,
         "/symbol LIKE 'ABCD'");
       amps_client_set_message_handler(client, receiveMessage, NULL);
 
       amps_client_send(client, m);
 
       sleep(10);
       return 0;
     }

In this example, we connect to AMPS and build an AMPS message to subscribe to the "orders" topic. Messages are filtered on the server: we're only sent messages whose "symbol" field contains "ABCD". We set our "receiveMessage" function to receive messages from the server as they arrive and write their data to stdout. If any errors occur while connecting, they're written to stdout as well.

Everything You Need

Ready to learn more? The AMPS C/C++ Client includes everything you need to get started: libraries, sample applications, developer's guide, and reference documentation. Each AMPS Client includes complete source code so you can fully learn and understand AMPS, and best integrate it into your environment.

Click here (Linux) or here (Windows) to download and start using the AMPS C/C++ Client. Once you've downloaded it, read the Developer Guide to get started.

If you need more help getting started, the 60East Technologies support and services team is ready to provide the support you need to help you CRANK UP THE AMPS.

The current release of the C client is version 5.3.4.1, which supports AMPS servers version 5.3 and earlier.