man page completed
parent
7530e073ed
commit
74b608045e
|
@ -45,8 +45,6 @@ int srv_write (const struct process *, const struct msg *m);
|
|||
|
||||
int srv_select (struct array_proc *, struct service *, struct array_proc *);
|
||||
|
||||
int getMaxFd(struct array_proc *);
|
||||
|
||||
// APPLICATION
|
||||
|
||||
// Initialize connection with unix socket
|
||||
|
|
|
@ -5,31 +5,25 @@ communication.h \- all functions explained
|
|||
.nf
|
||||
.B #include <communication.h>
|
||||
.sp
|
||||
// SERVICE
|
||||
.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_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 );
|
||||
.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_read (const struct process * " p ", char ** " buf ", size_t * " buf_size );
|
||||
.BI "int srv_write (const struct process * ", const char * " buf ", size_t " buf_size );
|
||||
.sp
|
||||
.BI "int srv_close (struct service * " srv );
|
||||
.BI "int srv_close_proc (struct process * " p );
|
||||
.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 );
|
||||
|
||||
// APPLICATION
|
||||
|
||||
// Initialize connection with unix socket
|
||||
// send the connection string to $TMP/<service>
|
||||
// fill srv->spath && srv->service_fd
|
||||
.BI "int app_connection (int " argc ", char ** " argv ", char ** " env ", struct service * " srv
|
||||
.BI " , const char * " service_name "
|
||||
.BI " , const char * " connection_str ", size_t " connection_str_size );
|
||||
.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 (struct service * " srv ", char ** " buf ", size_t * " msize );
|
||||
.BI "int app_write (struct service * " srv ", char * " buf ", size_t " msize );
|
||||
.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 );
|
||||
.BI "int app_close (struct service *" srv );
|
||||
|
||||
|
||||
.fi
|
||||
|
@ -39,19 +33,79 @@ The
|
|||
function let the service declare itself, create a new unix socket and listen.
|
||||
.I argc
|
||||
,
|
||||
.IR argv
|
||||
.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. \fBTODO\fR.
|
||||
.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 parameters of this structure, such as the unix socket path and the unix socket file descriptor in order to be able to receive new connections.
|
||||
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
|
||||
All the functions return an integer less than zero if there is an error.
|
||||
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.
|
||||
|
|
Reference in New Issue