Ninf Client API

This document gives Ninf Client API.

Overview

Our API provides following functions.

Ninf_call

This function calls Ninf function on a remote server. The first argument specifies server and function. Here is an example that calls "mmul" function on our server "etlninf.apgrid.org".
     Ninf_call("ninf://etlninf.apgrid.org:3000/mmul", n, A, B, C);
You can omit the server name and port. In such case, a default server will be used. Default server can be specified by environment variable "NINF_SERVER" and "NINF_SERVER_PORT", or Ninf_parse_arg. This function returns 0 if succeed, returns -1 if failed.

Ninf_call_sync

This function is almost same as Ninf_call, but it returns immediately. Using this function, you can invoke several sessions simultaneously. It returns non-negative ID if succeed, returns -1 if failed.
     id = Ninf_call_async("ninf://ninf.apgrid.org:3030/mmul", n, A, B, C);

Ninf_wait

This function wait for termination of one session specified by id. It returns 0 if succeed, returns -1 if failed.
     Ninf_wait(id);

Ninf_wait_all

This function wait for all sessions which invoked by Ninf_call_async.
     Ninf_wait_all();

Ninf_parse_arg

This function parse argument list for your client program and get default hostname and port. It recognizes "-server SERVER" and "-port PORT", and remove these arguments from your list. It returns new argc value. Here is an example showing typical usage.
main (int argc, char ** argv){
	argc = Ninf_parse_arg(argc, argv);
	...

Ninf_perror

This function produces an error massage on the standard error output, describing the last error encountered in Ninf_call. The argument string is printed first, then a colon and a blank, then the message and a newline. Here is an example showing typical usage.
   if (Ninf_call("mmul", n, A, B, C) < 0){
	Ninf_perror("Failed in mmul");
	exit();
   }