3 * $Id: conn.h,v 1.2 1999/05/15 10:33:32 mdw Exp $
5 * Nonblocking connect handling
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.2 1999/05/15 10:33:32 mdw
34 * Fix copyright notices.
36 * Revision 1.1 1999/05/14 21:01:14 mdw
37 * Integrated `select' handling bits from the background resolver project.
48 /*----- Header files ------------------------------------------------------*/
54 /*----- Data structures ---------------------------------------------------*/
56 /* --- The nonblocking connect structure --- */
59 sel_file writer; /* Select listener */
60 void (*func)(int /*fd*/, void */*p*/); /* Handler function */
61 void *p; /* Argument for handler function */
64 /*----- Functions provided ------------------------------------------------*/
66 /* --- @conn_init@ --- *
68 * Arguments: @conn *c@ = pointer to connection block
69 * @sel_state *s@ = pointer to select state to attach to
70 * @unsigned long saddr@ = source IP address
71 * @unsigned short sport@ = source port
72 * @unsigned long daddr@ = destination IP address
73 * @unsigned short dport@ = destination port
74 * @void (*func)(int fd, void *p) = handler function
75 * @void *p@ = argument for the handler function
79 * Use: Sets up a nonblocking connect job. The source address and
80 * port can be zero if you don't care. When the connection
81 * completes, the handler function is called with the connected
82 * socket as an argument. If the connect fails rather than
83 * completes, the handler is informed of this by being passed a
84 * negative file descriptor. In either case, the select job is
88 extern void conn_init(conn */*c*/, sel_state */*s*/,
89 unsigned long /*saddr*/,
90 unsigned short /*sport*/,
91 unsigned long /*daddr*/,
92 unsigned long /*dport*/,
93 void (*/*func*/)(int /*fd*/, void */*p*/),
96 /* --- @conn_kill@ --- *
98 * Arguments: @conn *c@ = pointer to connection to dispose of
102 * Use: Disposes of a connection when it's not wanted any more. The
103 * connect handler function is not called.
106 extern void conn_kill(conn */*c*/);
108 /*----- That's all, folks -------------------------------------------------*/