Added SILC Local Network Stream API
[runtime.git] / lib / silcutil / silclocalnetstream.h
1 /*
2
3   silclocalnetstream.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2008 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/Local Network Stream Interface
21  *
22  * DESCRIPTION
23  *
24  * Local network stream interface enables two or more processes to communicate
25  * with each other in the local machine using local network start.  The
26  * interface provides a form of interprocess communication (IPC) using network
27  * sockets.
28  *
29  ***/
30
31 #ifndef SILCLOCALNETSTREAM_H
32 #define SILCLOCALNETSTREAM_H
33
34 /****f* silcutil/silc_local_net_create_listener
35  *
36  * SYNOPSIS
37  *
38  *    SilcNetListener silc_local_net_create_listener(const char *filepath,
39  *                                                   SilcSchedule schedule,
40  *                                                   SilcNetCallback callback,
41  *                                                   void *context);
42  *
43  * DESCRIPTION
44  *
45  *    Creates a local network stream listener and returns a network server.
46  *    The `filepath' is a local filepath that must be used by the clients to
47  *    connect to the server.
48  *
49  *    The `callback' will be called when a client connects to the listener
50  *    with the `context'.  The returned listener must be closed by calling
51  *    silc_local_net_close_listener.
52  *
53  *    Clients can connect to the listener by calling the
54  *    silc_local_net_connect.
55  *
56  *    Returns NULL on error and set silc_errno.  If `schedule' is NULL this
57  *    will call silc_schedule_get_global to try to get global scheduler.
58  *
59  ***/
60 SilcNetListener silc_local_net_create_listener(const char *filepath,
61                                                SilcSchedule schedule,
62                                                SilcNetCallback callback,
63                                                void *context);
64
65 /****f* silcutil/silc_local_net_close_listener
66  *
67  * SYNOPSIS
68  *
69  *    void silc_local_net_close_listener(SilcNetListener local_listener);
70  *
71  * DESCRIPTION
72  *
73  *    Closes the local network stream listener.
74  *
75  ***/
76 void silc_local_net_close_listener(SilcNetListener local_listener);
77
78 /****f* silcutil/silc_local_net_connect
79  *
80  * SYNOPSIS
81  *
82  *    SilcAsyncOperation silc_local_net_connect(const char *filepath,
83  *                                              SilcSchedule schedule,
84  *                                              SilcNetCallback callback,
85  *                                              void *context);
86  *
87  * DESCRIPTION
88  *
89  *    Connects to the local network server at the provided `filepath'.  If
90  *    the `filepath' does not exist or is not valid local network listener
91  *    the connection will fail.
92  *
93  *    The `callback' with `context' will be called once the connection has
94  *    been created.
95  *
96  *    If `schedule' is NULL this will call silc_schedule_get_global to try
97  *    to get global scheduler.
98  *
99  ***/
100 SilcAsyncOperation silc_local_net_connect(const char *filepath,
101                                           SilcSchedule schedule,
102                                           SilcNetCallback callback,
103                                           void *context);
104
105 #endif /* SILCLOCALNETSTREAM_H */