1 |
/* Connection queues |
/* Connection queues |
2 |
|
|
3 |
Copyright (C) 1995 Free Software Foundation, Inc. |
Copyright (C) 1995, 2005 Free Software Foundation, Inc. |
4 |
|
|
5 |
Written by Miles Bader <miles@gnu.ai.mit.edu> |
Written by Miles Bader <miles@gnu.ai.mit.edu> |
6 |
|
|
23 |
|
|
24 |
#include <errno.h> |
#include <errno.h> |
25 |
|
|
26 |
/* Unknown types */ |
/* Forward. */ |
27 |
struct connq; |
struct connq; |
|
struct connq_request; |
|
28 |
struct sock; |
struct sock; |
29 |
|
|
30 |
/* Create a new listening queue, returning it in CQ. The resulting queue |
/* Create a new listening queue, returning it in CQ. The resulting queue |
35 |
/* Destroy a queue. */ |
/* Destroy a queue. */ |
36 |
void connq_destroy (struct connq *cq); |
void connq_destroy (struct connq *cq); |
37 |
|
|
38 |
/* Wait for a connection attempt to be made on CQ, and return the connecting |
/* Return a connection request on CQ. If SOCK is NULL, the request is |
39 |
socket in SOCK, and a request tag in REQ. If REQ is NULL, the request is |
left in the queue. If NOBLOCK is true, EWOULDBLOCK is returned |
40 |
left in the queue, otherwise connq_request_complete must be called on REQ |
when there are no immediate connections available. */ |
41 |
to allow the requesting thread to continue. If NOBLOCK is true, |
error_t connq_listen (struct connq *cq, int noblock, struct sock **sock); |
42 |
EWOULDBLOCK is returned when there are no immediate connections |
|
43 |
available. CQ should be unlocked. */ |
/* Try to connect SOCK with the socket listening on CQ. If NOBLOCK is |
44 |
error_t connq_listen (struct connq *cq, int noblock, |
true, then return EWOULDBLOCK if there are no connections |
45 |
struct connq_request **req, struct sock **sock); |
immediately available. On success, this call must be followed up |
46 |
|
either connq_connect_complete or connq_connect_cancel. */ |
47 |
/* Return the error code ERR to the thread that made the listen request REQ, |
error_t connq_connect (struct connq *cq, int noblock); |
48 |
returned from a previous connq_listen. */ |
|
49 |
void connq_request_complete (struct connq_request *req, error_t err); |
/* Follow up to connq_connect. Completes the connection, SOCK is the |
50 |
|
new server socket. */ |
51 |
|
void connq_connect_complete (struct connq *cq, struct sock *sock); |
52 |
|
|
53 |
|
/* Follow up to connq_connect. Cancel the connect. */ |
54 |
|
void connq_connect_cancel (struct connq *cq); |
55 |
|
|
56 |
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a |
/* Set CQ's queue length to LENGTH. Any sockets already waiting for a |
57 |
connections that are past the new length will fail with ECONNREFUSED. */ |
connections that are past the new length remain. */ |
58 |
error_t connq_set_length (struct connq *cq, int length); |
error_t connq_set_length (struct connq *cq, int length); |
59 |
|
|
|
/* Try to connect SOCK with the socket listening on CQ. If NOBLOCK is true, |
|
|
then return EWOULDBLOCK immediately when there are no immediate |
|
|
connections available. Neither SOCK nor CQ should be locked. */ |
|
|
error_t connq_connect (struct connq *cq, int noblock, struct sock *sock); |
|
|
|
|
60 |
#endif /* __CONNQ_H__ */ |
#endif /* __CONNQ_H__ */ |