chiark / gitweb /
New version number.
[mLib] / conn.h
CommitLineData
97f65b00 1/* -*-c-*-
2 *
a3ddb778 3 * $Id: conn.h,v 1.2 1999/05/15 10:33:32 mdw Exp $
97f65b00 4 *
5 * Nonblocking connect handling
6 *
a3ddb778 7 * (c) 1999 Straylight/Edgeware
97f65b00 8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: conn.h,v $
a3ddb778 33 * Revision 1.2 1999/05/15 10:33:32 mdw
34 * Fix copyright notices.
35 *
97f65b00 36 * Revision 1.1 1999/05/14 21:01:14 mdw
37 * Integrated `select' handling bits from the background resolver project.
38 *
39 */
40
41#ifndef CONN_H
42#define CONN_H
43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47
48/*----- Header files ------------------------------------------------------*/
49
50#ifndef SEL_H
51# include "sel.h"
52#endif
53
54/*----- Data structures ---------------------------------------------------*/
55
56/* --- The nonblocking connect structure --- */
57
58typedef struct conn {
59 sel_file writer; /* Select listener */
60 void (*func)(int /*fd*/, void */*p*/); /* Handler function */
61 void *p; /* Argument for handler function */
62} conn;
63
64/*----- Functions provided ------------------------------------------------*/
65
66/* --- @conn_init@ --- *
67 *
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
76 *
77 * Returns: ---
78 *
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
85 * then removed.
86 */
87
88extern 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*/),
94 void */*p*/);
95
96/* --- @conn_kill@ --- *
97 *
98 * Arguments: @conn *c@ = pointer to connection to dispose of
99 *
100 * Returns: ---
101 *
102 * Use: Disposes of a connection when it's not wanted any more. The
103 * connect handler function is not called.
104 */
105
106extern void conn_kill(conn */*c*/);
107
108/*----- That's all, folks -------------------------------------------------*/
109
110#ifdef __cplusplus
111 }
112#endif
113
114#endif