3 * $Id: conn.h,v 1.4 1999/05/26 21:08:01 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.4 1999/05/26 21:08:01 mdw
34 * Remove redundant structure member.
36 * Revision 1.3 1999/05/23 12:12:46 mdw
37 * Interface change to make the `conn' selector useful for generic stream
38 * sockets rather than just IPv4 ones.
40 * Revision 1.2 1999/05/15 10:33:32 mdw
41 * Fix copyright notices.
43 * Revision 1.1 1999/05/14 21:01:14 mdw
44 * Integrated `select' handling bits from the background resolver project.
55 /*----- Header files ------------------------------------------------------*/
57 #include <sys/types.h>
58 #include <sys/socket.h>
64 /*----- Data structures ---------------------------------------------------*/
66 /* --- The nonblocking connect structure --- */
69 sel_file writer
; /* Select listener */
70 void (*func
)(int /*fd*/, void */
*p*/
); /* Handler function */
71 void *p
; /* Argument for handler function */
74 /*----- Functions provided ------------------------------------------------*/
76 /* --- @conn_init@ --- *
78 * Arguments: @conn *c@ = pointer to connection block
79 * @sel_state *s@ = pointer to select state to attach to
80 * @int fd@ = file descriptor of socket to connect
81 * @struct sockaddr *dst@ = destination address
82 * @int dsz@ = size of destination address
83 * @void (*func)(int fd, void *p) = handler function
84 * @void *p@ = argument for the handler function
88 * Use: Sets up a nonblocking connect job. The socket should already
89 * be bound if you care about that sort of thing. When the
90 * connection completes, the handler function is called with the
91 * connected socket as an argument. If the connect fails rather
92 * than completes, the socket is closed, and the handler is
93 * informed of this by being passed a negative file descriptor.
94 * In either case, the select job is then removed.
97 extern void conn_init(conn */
*c*/
, sel_state */
*s*/
, int /*fd*/,
98 struct sockaddr */
*dst*/
, int /*dsz*/,
99 void (*/
*func*/
)(int /*fd*/, void */
*p*/
),
102 /* --- @conn_kill@ --- *
104 * Arguments: @conn *c@ = pointer to connection to dispose of
108 * Use: Disposes of a connection when it's not wanted any more. The
109 * connect handler function is not called.
112 extern void conn_kill(conn */
*c*/
);
114 /*----- That's all, folks -------------------------------------------------*/