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
|
/* Connection queues
Copyright (C) 1995, 2012 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef __CONNQ_H__
#define __CONNQ_H__
#include <errno.h>
/* Forward. */
struct connq;
struct sock;
/* Create a new listening queue, returning it in CQ. The resulting queue
will be of zero length, that is it won't allow connections unless someone
is already listening (change this with connq_set_length). */
error_t connq_create (struct connq **cq);
/* Destroy a queue. */
void connq_destroy (struct connq *cq);
/* Return a connection request on CQ. If SOCK is NULL, the request is
left in the queue. If NOBLOCK is true, EWOULDBLOCK is returned
when there are no immediate connections available. */
error_t connq_listen (struct connq *cq, int noblock, struct sock **sock);
/* Try to connect SOCK with the socket listening on CQ. If NOBLOCK is
true, then return EWOULDBLOCK if there are no connections
immediately available. On success, this call must be followed up
either connq_connect_complete or connq_connect_cancel. */
error_t connq_connect (struct connq *cq, int noblock);
/* Follow up to connq_connect. Completes the connection, SOCK is the
new server socket. */
void connq_connect_complete (struct connq *cq, struct sock *sock);
/* Follow up to connq_connect. Cancel the connect. */
void connq_connect_cancel (struct connq *cq);
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a
connections that are past the new length remain. */
error_t connq_set_length (struct connq *cq, int length);
#endif /* __CONNQ_H__ */
|