Answer the question
In order to leave comments, you need to log in
How is the external API of the program created?
The bottom line is this: for example, I created some program in C (let there be a database), launched it and it works for itself.
#include <stdio.h>
#include "mongo.h"
int main() {
mongo conn[1];
status = mongo_connect( conn, "127.0.0.1", 27017 );
if( status != MONGO_OK ) {
switch ( conn->err ) {
case MONGO_CONN_SUCCESS: printf( "connection succeeded\n" ); break;
case MONGO_CONN_BAD_ARG: printf( "bad arguments\n" ); return 1;
case MONGO_CONN_NO_SOCKET: printf( "no socket\n" ); return 1;
case MONGO_CONN_FAIL: printf( "connection failed\n" ); return 1;
case MONGO_CONN_NOT_MASTER: printf( "not master\n" ); return 1;
}
}
mongo_destroy( conn );
return 0;
}
Answer the question
In order to leave comments, you need to log in
> 1 How to create an API for it (read the driver)?
The original question is not correct. API is not a driver. never really at all.
> 2 What will be used for the interaction between the driver and the working base (sockets maybe, maybe something else)?
And whatever you want, it will be used. Though messages, though sockets, though a file on a disk. You are a programmer, who will forbid you.
> Can I call some function from the driver
?
You write on a sisechka, so no one can tell you a decree, you can implement almost anything. As it will be more convenient for the user to communicate with the database, create such an API.
Judging by the code, mongo works through a TCP socket.
In Unix, there are the following types of IPC (inter process communications - interprocessor communication)
Russian Wikipedia
article 1.Pipe
2.FIFO, or named pipe
3.Socket and Unix Domain Socket
4.Message Queue
5.Signal
6.Semaphore
7.Shared memory
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question