next up previous contents
Next: A.3 Requesting Device Access Up: A. The C Client Previous: A.1 Debug Information   Contents

A.2 Connecting to the Server

The C client makes no use of static data structures for maintaining connection information; rather the user must always supply a pointer to a properly initialized connection structure, of type player_connection_t. This structure is initialized by player_connect():

   * connects to server listening at host:port.  conn is filled in with
   * relevant information, and is used in subsequent player function
   * calls
   * Returns:
   *    0 if everything is OK (connection opened)
   *   -1 if something went wrong (connection NOT opened)
  int player_connect(player_connection_t* conn, const char* host, int port);

Note that the connection will be blocking. A simple example:

  player_connection_t conn;

  /* Connect to Player server */
  if(player_connect(&conn, "localhost", PLAYER_PORTNUM))