Next: , Previous: , Up: Writing a Client Application   [Contents]

4.3.2 Writing a Client Library

The first and most important step in writing a client library is to decide on an API for the library. Typical API calls include connecting to the service, performing application-specific requests and cleaning up. Many examples for such service APIs can be found in the gnunet/src/include/gnunet\_*\_service.h files.

Then, a client-service protocol needs to be designed. This typically involves defining various message formats in a header that will be included by both the service and the client library (but is otherwise not shared and hence located within the service’s directory and not installed by make install). Each message must start with a struct GNUNET\_MessageHeader and must be shorter than 64k. By convention, all fields in IPC (and P2P) messages must be in big-endian format (and thus should be read using ntohl and similar functions and written using htonl and similar functions). Unique message types must be defined for each message struct in the gnunet\_protocols.h header (or an extension-specific include file).