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
3.8 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 "int srv_init (int "argc ", char **" argv ", char **" env ", struct service *" srv "
.BI " , const char *" service_name );
.BI "int srv_accept (struct service *" srv ", struct process *" p );
.sp
.BI "int srv_read (const struct process *" p ", struct msg *" message );
.BI "int srv_write (const struct process *" p ", const struct msg *" message );
.sp
.BI "int srv_close (struct service *" srv );
.BI "int srv_close_proc (struct process *" p );
.BI "int srv_select (struct array_proc *" fds ", struct service *" srv ", struct array_proc *" readfds );
.BI "int app_connection (int " argc ", char **" argv ", char **" env ", struct service *" srv
.BI " , const char *" service_name "
.BI " , const char *" connection_buffer ", size_t " bufsize );
.sp
.BI "int app_read (const struct service *" srv ", struct msg *" message );
.BI "int app_write (const struct service *" srv ", const struct msg *" message );
.sp
.BI "int app_close (struct service *" srv );
.fi
.SH DESCRIPTION
The
.BR srv_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 service\fR that should be filled (index and version parameters).
The \fBsrv_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 srv_accept ()
function accepts new connections.
.IR p
parameter is the client process that will be provided after the connection.
.PP
The
.BR srv_read ()
and
.BR srv_write ()
functions take respectively a message to read from, and a message to write to a process.
.PP
The
.BR srv_close_proc ()
and
.BR srv_close ()
functions terminate respectively a process (closing its unix socket) and the service (closing and removing its named unix socket).
.PP
The
.BR srv_select ()
takes three arguments,
.IR *ap
an array of processes you want to listen on,
.IR *srv
the service which receives new connections and
.IR *ap_read
an array of processes which have sent a message we need to read.
.PP
The
.BR app_connection ()
function takes
.I argc
,
.IR *argv
and
.IR *env
in argument for latter use.
It takes
.IR *srv
the pointer to the \fBstruct 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 app_read ()
and
.BR app_write ()
functions take respectively a message to read from, and a message to write to the service.
.PP
The
.BR app_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 srv_select()
if there is a new connection, the function will return \fBCONNECTION\fR, if there is one or more processes talking the function will return \fBAPPLICATION\fR and finally if there are both a new connection and a process talking the function will return \fBCON_APP\fR.