.\" -*-nroff-*- .TH conn 3 "23 May 1999" "Straylight/Edgeware" "mLib utilities library" .\" @conn_init .\" @conn_kill .SH NAME conn \- selector for nonblocking connections .SH SYNOPSIS .nf .B "#include " .BI "void conn_init(conn *" c ", sel_state *" s ", int " fd , .BI " struct sockaddr *" dst ", int " dsz , .BI " void (*" func ")(int " fd ", void *" p ), .BI " void *" p ); .BI "void conn_kill(conn *" c ); .fi .SH DESCRIPTION The .B conn selector manages a nonblocking connection to a remote socket. The selector's state is maintained in an object of type .BR conn . .PP Before use, a .B conn selector must be initialized. This requires a call to .B conn_init with a fairly large number of arguments: .TP .BI "conn *" c Pointer to .B conn object which needs to be initialized. .TP .BI "sel_state *" s Pointer to a multiplexor object (type .BR sel_state ) to which this selector should be attached. See .BR sel (3) for more details about multiplexors, and how this whole system works. .TP .BI "int " fd File descriptor for the socket you want to connect. This becomes the `property' of the .B conn selector until the connection attempt finishes. For example, if there's an error, the descriptor will be closed. .TP .BI "struct sockaddr *" dst Pointer to destination socket address for the connection. Make sure that the address has the right family. .TP .BI "int " dsz Size of the destination socket address. .TP .BI "void (*" func ")(int " fd ", void *" p ) A function to call when the connection is complete. It is passed the file descriptor of the connected socket, and the pointer passed to .B conn_init as the .I p argument. If the connection failed, a file descriptor value of \-1 is passed, and the global .B errno value is set appropriately. .TP .BI "void *" p An arbitrary pointer whose value is passed to the handler function when the connection finishes. .PP If you want to cancel the connection attempt before it finishes, call .B conn_kill with the address of the selector. The file descriptor is closed, and the selector becomes safe to be discarded. .SH "SEE ALSO" .BR connect (2), .BR sel (3), .BR mLib (3). .SH AUTHOR Mark Wooding,