chiark / gitweb /
More portability enhancements.
[mLib] / man / conn.3
CommitLineData
b6b9d458 1.\" -*-nroff-*-
2.TH conn 3mLib "23 May 1999" mLib
3.SH NAME
4conn \- selector for nonblocking connections
5.SH SYNOPSIS
6.nf
7.B "#include <mLib/conn.h>
8
9.BI "void conn_init(conn *" c ", sel_state *" s ", int " fd ,
10.BI " struct sockaddr *" dst ", int " dsz ,
11.BI " void (*" func ")(int " fd ", void *" p ),
12.BI " void *" p );
13
14.BI "void conn_kill(conn *" c );
15.fi
16.SH DESCRIPTION
17The
18.B conn
19selector manages a nonblocking connection to a remote socket. The
20selector's state is maintained in an object of type
21.BR conn .
22.PP
23Before use, a
24.B conn
25selector must be initialized. This requires a call to
26.B conn_init
27with a fairly large number of arguments:
28.TP
29.I c
30Pointer to
31.B conn
32object which needs to be initialized.
33.TP
34.I s
35Pointer to a multiplexor object (type
36.BR sel_state )
37to which this selector should be attached. See
38.BR sel (3mLib)
39for more details about multiplexors, and how this whole system works.
40.TP
41.I fd
42File descriptor for the socket you want to connect. This becomes the
43`property' of the
44.B conn
45selector until the connection attempt finishes. For example, if there's
46an error, the descriptor will be closed.
47.TP
48.I dst
49Pointer to destination socket address for the connection. Make sure
50that the address has the right family.
51.TP
52.I dsz
53Size of the destination socket address.
54.TP
55.I func
56A function to call when the connection is complete. It is passed the
57file descriptor of the connected socket, and the pointer passed
58to
59.B conn_init
60as the
61.I p
62argument. If the connection failed, a file descriptor value of \-1 is
63passed, and the global
64.B errno
65value is set appropriately.
66.TP
67.I p
68An arbitrary pointer whose value is passed to the handler function when
69the connection finishes.
70.PP
71If you want to cancel the connection attempt before it finishes, call
72.B conn_kill
73with the address of the selector. The file descriptor is closed, and
74the selector becomes safe to be discarded.
75.SH AUTHOR
76Mark Wooding, <mdw@nsict.org>