Obsolete
/
libipc-old
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
libipc-old/man/communication.h.3

112 lines
4.1 KiB
Groff

.TH COMMUNICATION.H 3 2016-12-20 "" "Linux Programmer's Manual"
.SH NAME
communication.h \- all functions explained
.SH SYNOPSIS
.nf
.B #include <communication.h>
.sp
.BI "int32_t ipc_server_init (int32_t "argc ", char **" argv ", char **" env ", struct ipc_service *" srv "
.BI " , const char *" service_name );
.BI "int32_t ipc_server_accept (struct ipc_service *" srv ", struct ipc_client *" p );
.sp
.BI "int32_t ipc_server_read (const struct ipc_client *" p ", struct ipc_message *" message );
.BI "int32_t ipc_server_write (const struct ipc_client *" p ", const struct ipc_message *" message );
.sp
.BI "int32_t ipc_server_close (struct ipc_service *" srv );
.BI "int32_t ipc_server_close_client (struct ipc_client *" p );
.BI "int32_t ipc_server_select (struct ipc_clients *" fds ", struct ipc_service *" srv ", struct ipc_clients *" readfds );
.BI "int32_t ipc_application_connection (int32_t " argc ", char **" argv ", char **" env ", struct ipc_service *" srv
.BI " , const char *" service_name "
.BI " , const char *" connection_buffer ", size_t " bufsize );
.sp
.BI "int32_t ipc_application_read (const struct ipc_service *" srv ", struct ipc_message *" message );
.BI "int32_t ipc_application_write (const struct ipc_service *" srv ", const struct ipc_message *" message );
.sp
.BI "int32_t ipc_application_close (struct ipc_service *" srv );
.fi
.SH DESCRIPTION
The
.BR ipc_server_init ()
function let the service declare itself, create a new unix socket and listen.
.I argc
,
.IR *argv
and
.IR *env
should be passed to the function in order to automatically change the behavior of the program without the application being modified.
.I *srv
is the pointer to the \fBstruct ipc_service\fR that should be filled (index and version parameters).
The \fBserver_init()\fR function will fill the rest of the elements of this structure, such as the unix socket path and the unix socket file descriptor in order to be able to receive new connections.
.PP
The
.BR ipc_server_accept ()
function accepts new connections.
.IR p
parameter is the client client that will be provided after the connection.
.PP
The
.BR ipc_server_read ()
and
.BR ipc_server_write ()
functions take respectively a message to read from, and a message to write to a client.
.PP
The
.BR ipc_server_close_client ()
and
.BR ipc_server_close ()
functions terminate respectively a client (closing its unix socket) and the service (closing and removing its named unix socket).
.PP
The
.BR ipc_server_select ()
takes three arguments,
.IR *ap
an array of clientes you want to listen on,
.IR *srv
the service which receives new connections and
.IR *ap_read
an array of clientes which have sent a message we need to read.
.PP
The
.BR ipc_application_connection ()
function takes
.I argc
,
.IR *argv
and
.IR *env
in argument for latter use.
It takes
.IR *srv
the pointer to the \fBstruct ipc_service\fR that should be filled (index and version parameters) and
will fill the rest of the elements of this structure, such as the unix socket path and the unix socket file descriptor of the service in order to be able to talk to it.
The function also takes
.IR *service_name
to deduce the pipe's name of the service.
Finally, the function takes
.IR *connection_buffer
and
.IR bufsize
arguments to send a buffer in the first message value for the connection, which is useful when the service needs configuration.
The function finally connects itself to the service.
\fBIn a near future, this function will be completed to invoke transparently the remote service\fR.
.PP
The
.BR ipc_application_read ()
and
.BR ipc_application_write ()
functions take respectively a message to read from, and a message to write to the service.
.PP
The
.BR ipc_application_close ()
function finally ends the communication to the service.
.SH RETURN VALUE
Most of the functions return an integer less than zero if there is an error.
.PP
For
.BR ipc_server_select()
if there is a new connection, the function will return \fBCONNECTION\fR, if there is one or more clientes talking the function will return \fBAPPLICATION\fR and finally if there are both a new connection and a client talking the function will return \fBCON_APP\fR.