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