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