Detailed Description

Before calling any other function of the library, calling brlapi_openConnection() is needed to establish a connection to BrlAPI 's server. When the connection is not needed any more, brlapi_closeConnection() must be called to close the connection.

Macro Definition Documentation

#define BRLAPI_AUTHKEYFILE 'brlapi.key'

Default name of the file containing BrlAPI 's authorization key

This name is relative to BRLAPI_ETCDIR

#define BRLAPI_DEFAUTH \fBBRLAPI_ETCDIR\fP '/' \fBBRLAPI_AUTHKEYFILE\fP

Default authorization setting

#define BRLAPI_ETCDIR '/etc'

brltty 's settings directory

This is where authorization key and driver-dependent key names are found for instance.

#define BRLAPI_SETTINGS_INITIALIZER { NULL, NULL }

Allows to initialize a structure of type brlapi_connectionSettings_t * with default values.

#define BRLAPI_SOCKETPATH '/var/lib/BrlAPI'

Default unix path on which connections to BrlAPI can be established

#define BRLAPI_SOCKETPORT '4101'

#define BRLAPI_SOCKETPORTNUM 4101

Default port number on which connections to BrlAPI can be established

Typedef Documentation

typedef int \fBbrlapi_fileDescriptor\fP

Function Documentation

void \fBBRLAPI_STDCALL\fP brlapi__closeConnection (\fBbrlapi_handle_t\fP *handle)

\fBbrlapi_fileDescriptor\fP \fBBRLAPI_STDCALL\fP brlapi__openConnection (\fBbrlapi_handle_t\fP *handle, const \fBbrlapi_connectionSettings_t\fP *desiredSettings, \fBbrlapi_connectionSettings_t\fP *actualSettings)

void \fBBRLAPI_STDCALL\fP brlapi_closeConnection (void)

Cleanly close the socket

This function locks until a closing acknowledgement is received from the server. The socket is then freed, so the file descriptor brlapi_openConnection() gave has no meaning any more

\fBbrlapi_fileDescriptor\fP \fBBRLAPI_STDCALL\fP brlapi_openConnection (const \fBbrlapi_connectionSettings_t\fP *desiredSettings, \fBbrlapi_connectionSettings_t\fP *actualSettings)

Open a socket and connect it to BrlAPI 's server

This function first loads an authorization key as specified in settings. It then creates a TCP socket and connects it to the specified machine, on the specified port. It writes the authorization key on the socket and waits for acknowledgement.

Returns:

the file descriptor, or -1 on error

Note:

The file descriptor is returned in case the client wants to communicate with the server without using libbrlapi functions. If it uses them however, it won't have to pass the file descriptor later, since the library keeps a copy of it. But that also means that brlapi_openConnection() may be called several times, but libbrlapi functions will always work with the last call's descriptor

Example:

1 if (brlapi_openConnection(&settings,&settings)<0) {
2  fprintf(stderr,"couldn't connect to BrlAPI at %s: %s\n",
3   settings.host, brlapi_strerror(&brlapi_error));
4  exit(1);
5 }

Errors:

BrlAPI might not be on this TCP port, the host name might not be resolvable, the authorization may fail,...

Parameters:

desiredSettings this gives the desired connection parameters, as described in brlapi_connectionSettings_t. If NULL, defaults values are used, so that it is generally a good idea to give NULL as default, and only fill a brlapi_connectionSettings_t structure when the user gave parameters to the program for instance;

actualSettings if not NULL, parameters which were actually used are stored here, if the application ever needs them.

See also:

brlapi_connectionSettings_t brlapi_writePacket() brlapi_readPacketHeader() brlapi_readPacketContent() brlapi_readPacket()

Author

Generated automatically by Doxygen for BrlAPI from the source code.