Files
mongo/examples/c/ex_process.c
Michael Cahill 84c3666460 Incorporated Keith's latest feedback, switched XXX to @todo...
--HG--
branch : mjc
rename : docs/src/overview.dox => docs/src/introduction.dox
rename : include/wiredtiger.h => include/wiredtiger_ext.h
2011-01-06 21:45:04 +11:00

41 lines
1.0 KiB
C

/*
* ex_process.c
* Copyright (c) 2010 WiredTiger, Inc. All rights reserved.
*
* This is an example demonstrating how to connect to a database from multiple
* processes.
*/
#include <stdio.h>
#include <string.h>
#include <wiredtiger.h>
const char *home = "WT_TEST";
int main()
{
int ret;
WT_CONNECTION *conn;
WT_SESSION *session;
/* Open a connection to the database, creating it if necessary. */
if ((ret = wiredtiger_open(home, NULL, "create,share", &conn)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
/* Open a session for the current thread's work. */
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0)
fprintf(stderr, "Error opening a session on %s: %s\n",
home, wiredtiger_strerror(ret));
/* XXX Do some work... */
/* Note: closing the connection implicitly closes open session(s). */
if ((ret = conn->close(conn, NULL)) != 0)
fprintf(stderr, "Error connecting to %s: %s\n",
home, wiredtiger_strerror(ret));
return (ret);
}