aboutsummaryrefslogtreecommitdiffstats
path: root/libcoopgamma_synchronise.3
blob: 70d2f63bb64d78e303926de08504ef11c010f11f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.TH LIBCOOPGAMMA_SYNCHRONISE 3 LIBCOOPGAMMA
.SH "NAME"
libcoopgamma_synchronise - Wait for the next message to be received
.SH "SYNOPSIS"
.nf
#include <libcoopgamma.h>

int libcoopgamma_synchronise(libcoopgamma_context_t *restrict \fIctx\fP,
                             libcoopgamma_async_context_t *restrict \fIpending\fP,
                             size_t \fIn\fP, size_t *restrict \fIselected\fP);
.fi
.P
Link with
.IR -lcoopgamma .
.SH "DESCRIPTION"
The
.BR libcoopgamma_synchronise ()
function waits until the next message for
.I ctx
to be received and selects the context for the
asynchronous call for which the received message
is a response.
.I pending
shall list thes contexts for all pending asynchronous
call. The number of pending asynchronous call shall be
passed to the function via the
.I n
parameter. Once a full message as been received
.I *selected
is set to the index of the context in
.I pending
representing the context for the asynchronous call
to which the received message is a response.
.SH "RETURN VALUES"
Upon successful completion, the
.BR libcoopgamma_synchronise ()
function returns 0. On error, -1 is returned and
.I errno
is set appropriately.
.SH "ERRORS"
The
.BR libcoopgamma_synchronise ()
function may fail for any reason specified for
.BR realloc (3),
or
.BR recv (3).
Particularly interesting exceptional
conditions, that are not errors proper, include
those indicated by the following values on
.IR errno :
.TP
.B EINTR
The function was interrupted by a signal. When
this happens, just resume be calling the functon
again.
.TP
.BR EAGAIN " or " EWOULDBLOCK
The communication is nonblocking and no more
data is ready to be read, the buffer between
the server and the client has been depleted,
When this happens, wait a short period of time
and call the function again to resume.
.BR select (3)
or similar function can be used to wait until
.I ctx->fd
is readable.
.TP
.B ECONNREST
The connection to the server has closed.
.P
The function may also fail for the following reasons:
.TP
.B EBADMSG
A corrupt message has been received. Call the
function again to ge the next message.
.TP
.B ENOTRECOVERABLE
A corrupt message has been received. The corruption
is too severe for recovery. You may either exit
or disconnection and connection again.
.TP
0
The receive message does not match any of the
.I n
first contexts in
.IR pending .
.SH "SEE ALSO"
.BR libcoopgamma_flush (3),
.BR libcoopgamma_set_nonblocking (3),
.BR libcoopgamma_skip_message (3),
.BR libcoopgamma_get_crtcs_recv (3),
.BR libcoopgamma_get_gamma_info_recv (3),
.BR libcoopgamma_get_gamma_recv (3),
.BR libcoopgamma_set_gamma_recv (3)