1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
4 * Copyright © 2009 Codethink Limited
5 * Copyright © 2009 Red Hat, Inc
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors: Christian Kellner <gicmo@gnome.org>
21 * Samuel Cormier-Iijima <sciyoshi@gmail.com>
22 * Ryan Lortie <desrt@desrt.ca>
23 * Alexander Larsson <alexl@redhat.com>
24 */
25
26#ifndef __G_SOCKET_LISTENER_H__
27#define __G_SOCKET_LISTENER_H__
28
29#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
30#error "Only <gio/gio.h> can be included directly."
31#endif
32
33#include <gio/giotypes.h>
34
35G_BEGIN_DECLS
36
37#define G_TYPE_SOCKET_LISTENER (g_socket_listener_get_type ())
38#define G_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
39 G_TYPE_SOCKET_LISTENER, GSocketListener))
40#define G_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
41 G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
42#define G_IS_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
43 G_TYPE_SOCKET_LISTENER))
44#define G_IS_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
45 G_TYPE_SOCKET_LISTENER))
46#define G_SOCKET_LISTENER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
47 G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
48
49typedef struct _GSocketListenerPrivate GSocketListenerPrivate;
50typedef struct _GSocketListenerClass GSocketListenerClass;
51
52/**
53 * GSocketListenerClass:
54 * @changed: virtual method called when the set of socket listened to changes
55 *
56 * Class structure for #GSocketListener.
57 **/
58struct _GSocketListenerClass
59{
60 GObjectClass parent_class;
61
62 void (* changed) (GSocketListener *listener);
63
64 void (* event) (GSocketListener *listener,
65 GSocketListenerEvent event,
66 GSocket *socket);
67
68 /* Padding for future expansion */
69 void (*_g_reserved2) (void);
70 void (*_g_reserved3) (void);
71 void (*_g_reserved4) (void);
72 void (*_g_reserved5) (void);
73 void (*_g_reserved6) (void);
74};
75
76struct _GSocketListener
77{
78 GObject parent_instance;
79 GSocketListenerPrivate *priv;
80};
81
82GLIB_AVAILABLE_IN_ALL
83GType g_socket_listener_get_type (void) G_GNUC_CONST;
84
85GLIB_AVAILABLE_IN_ALL
86GSocketListener * g_socket_listener_new (void);
87
88GLIB_AVAILABLE_IN_ALL
89void g_socket_listener_set_backlog (GSocketListener *listener,
90 int listen_backlog);
91
92GLIB_AVAILABLE_IN_ALL
93gboolean g_socket_listener_add_socket (GSocketListener *listener,
94 GSocket *socket,
95 GObject *source_object,
96 GError **error);
97GLIB_AVAILABLE_IN_ALL
98gboolean g_socket_listener_add_address (GSocketListener *listener,
99 GSocketAddress *address,
100 GSocketType type,
101 GSocketProtocol protocol,
102 GObject *source_object,
103 GSocketAddress **effective_address,
104 GError **error);
105GLIB_AVAILABLE_IN_ALL
106gboolean g_socket_listener_add_inet_port (GSocketListener *listener,
107 guint16 port,
108 GObject *source_object,
109 GError **error);
110GLIB_AVAILABLE_IN_ALL
111guint16 g_socket_listener_add_any_inet_port (GSocketListener *listener,
112 GObject *source_object,
113 GError **error);
114
115GLIB_AVAILABLE_IN_ALL
116GSocket * g_socket_listener_accept_socket (GSocketListener *listener,
117 GObject **source_object,
118 GCancellable *cancellable,
119 GError **error);
120GLIB_AVAILABLE_IN_ALL
121void g_socket_listener_accept_socket_async (GSocketListener *listener,
122 GCancellable *cancellable,
123 GAsyncReadyCallback callback,
124 gpointer user_data);
125GLIB_AVAILABLE_IN_ALL
126GSocket * g_socket_listener_accept_socket_finish (GSocketListener *listener,
127 GAsyncResult *result,
128 GObject **source_object,
129 GError **error);
130
131
132GLIB_AVAILABLE_IN_ALL
133GSocketConnection * g_socket_listener_accept (GSocketListener *listener,
134 GObject **source_object,
135 GCancellable *cancellable,
136 GError **error);
137
138GLIB_AVAILABLE_IN_ALL
139void g_socket_listener_accept_async (GSocketListener *listener,
140 GCancellable *cancellable,
141 GAsyncReadyCallback callback,
142 gpointer user_data);
143
144GLIB_AVAILABLE_IN_ALL
145GSocketConnection * g_socket_listener_accept_finish (GSocketListener *listener,
146 GAsyncResult *result,
147 GObject **source_object,
148 GError **error);
149
150GLIB_AVAILABLE_IN_ALL
151void g_socket_listener_close (GSocketListener *listener);
152
153G_END_DECLS
154
155#endif /* __G_SOCKET_LISTENER_H__ */
156

source code of include/glib-2.0/gio/gsocketlistener.h