libmongo-client  0.1.6.1
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
Macros | Functions
Mongo Client

Macros

#define MONGO_CONN_LOCAL   -1
 Constant to signal that a connection is local (unix socket).

Functions

mongo_connection * mongo_connect (const char *address, int port)
 Connect to a MongoDB server.
void mongo_disconnect (mongo_connection *conn)
 Disconnect from a MongoDB server.
gboolean mongo_packet_send (mongo_connection *conn, const mongo_packet *p)
 Sends an assembled command packet to MongoDB.
mongo_packet * mongo_packet_recv (mongo_connection *conn)
 Receive a packet from MongoDB.
gint32 mongo_connection_get_requestid (const mongo_connection *conn)
 Get the last requestID from a connection object.
gboolean mongo_connection_set_timeout (mongo_connection *conn, gint timeout)
 Set a timeout for read/write operations on a connection.

Detailed Description


Macro Definition Documentation

#define MONGO_CONN_LOCAL   -1

Constant to signal that a connection is local (unix socket).

When passed to mongo_connect() or mongo_sync_connect() as the port parameter, it signals that the address is to be interpreted as a unix socket path, not a hostname or IP.


Function Documentation

mongo_connection* mongo_connect ( const char *  address,
int  port 
)

Connect to a MongoDB server.

Connects to a single MongoDB server.

Parameters:
addressis the address of the server (IP or unix socket path).
portis the port to connect to, or MONGO_CONN_LOCAL if address is a unix socket.
Returns:
A newly allocated mongo_connection object or NULL on error. It is the responsibility of the caller to free it once it is not used anymore.
gint32 mongo_connection_get_requestid ( const mongo_connection *  conn)

Get the last requestID from a connection object.

Parameters:
connis the connection to get the requestID from.
Returns:
The last requestID used, or -1 on error.
gboolean mongo_connection_set_timeout ( mongo_connection *  conn,
gint  timeout 
)

Set a timeout for read/write operations on a connection.

On systems that support it, set a timeout for read/write operations on a socket.

Parameters:
connis the connection to set a timeout on.
timeoutis the timeout to set, in milliseconds.
Returns:
TRUE on success, FALSE otherwise.
Note:
The timeout is not preserved accross reconnects, if using the Sync API, however. It only applies to the active connection, and nothing else.
void mongo_disconnect ( mongo_connection *  conn)

Disconnect from a MongoDB server.

Parameters:
connis the connection object to disconnect from.
Note:
This also frees up the object.
mongo_packet* mongo_packet_recv ( mongo_connection *  conn)

Receive a packet from MongoDB.

Parameters:
connis the connection to use for receiving.
Returns:
A response packet, or NULL upon error.
gboolean mongo_packet_send ( mongo_connection *  conn,
const mongo_packet *  p 
)

Sends an assembled command packet to MongoDB.

Parameters:
connis the connection to use for sending.
pis the packet to send.
Returns:
TRUE on success, when the whole packet was sent, FALSE otherwise.