#include "asynch.h" #include "my_task.h" // if all went well, this gets called void result_ready(char* server_key, void *result, int size, char last) { // size should be sizeof(int) int * i_ptr = (int *)result; printf("I received %d from server %s\n",*i_ptr,server_key); // last should be one since sizeof(int) is smaller than MAX_RESULT_SIZE if (last) { printf("End of result\n"); } } // if things went bad, this gets called void error(char *server_key, struct task *orig_request) { struct adder_task *task = (struct adder_task *)orig_request; printf("When sending task ID %d to add %d with %d to %s \n",task->id,task->arg1,task->arg2,server_key); printf(" ERROR NO : %ld\n",asynch_errno); printf(" ERROR: %s\n",strasyncherror(asynch_errno)); } int main(int argc, char* argv[]) { struct adder_task my_task; // init the structure bzero(&my_task, sizeof(my_task)); // set up some details my_task.id=234; my_task.arg1=22; my_task.arg2=5; // make the call // argv[1] will contain a key to the server // should check that return code == 0 (omitted) callAsych(argv[1],(struct task *)&my_task,result_ready,error); while (1); return 0; }