Initial commit
[platform/upstream/glib2.0.git] / gio / gsocketlistener.h
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 program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published
9  * by the Free Software Foundation; either version 2 of the licence or (at
10  * 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, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * Authors: Christian Kellner <gicmo@gnome.org>
23  *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
24  *          Ryan Lortie <desrt@desrt.ca>
25  *          Alexander Larsson <alexl@redhat.com>
26  */
27
28 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
29 #error "Only <gio/gio.h> can be included directly."
30 #endif
31
32 #ifndef __G_SOCKET_LISTENER_H__
33 #define __G_SOCKET_LISTENER_H__
34
35 #include <gio/giotypes.h>
36
37 G_BEGIN_DECLS
38
39 #define G_TYPE_SOCKET_LISTENER                              (g_socket_listener_get_type ())
40 #define G_SOCKET_LISTENER(inst)                             (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
41                                                              G_TYPE_SOCKET_LISTENER, GSocketListener))
42 #define G_SOCKET_LISTENER_CLASS(class)                      (G_TYPE_CHECK_CLASS_CAST ((class),                       \
43                                                              G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
44 #define G_IS_SOCKET_LISTENER(inst)                          (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
45                                                              G_TYPE_SOCKET_LISTENER))
46 #define G_IS_SOCKET_LISTENER_CLASS(class)                   (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
47                                                              G_TYPE_SOCKET_LISTENER))
48 #define G_SOCKET_LISTENER_GET_CLASS(inst)                   (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
49                                                              G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
50
51 typedef struct _GSocketListenerPrivate                      GSocketListenerPrivate;
52 typedef struct _GSocketListenerClass                        GSocketListenerClass;
53
54 /**
55  * GSocketListenerClass:
56  * @changed: virtual method called when the set of socket listened to changes
57  **/
58 struct _GSocketListenerClass
59 {
60   GObjectClass parent_class;
61
62   void (* changed) (GSocketListener *listener);
63
64   /* Padding for future expansion */
65   void (*_g_reserved1) (void);
66   void (*_g_reserved2) (void);
67   void (*_g_reserved3) (void);
68   void (*_g_reserved4) (void);
69   void (*_g_reserved5) (void);
70   void (*_g_reserved6) (void);
71 };
72
73 struct _GSocketListener
74 {
75   GObject parent_instance;
76   GSocketListenerPrivate *priv;
77 };
78
79 GType                   g_socket_listener_get_type                      (void) G_GNUC_CONST;
80
81 GSocketListener *       g_socket_listener_new                           (void);
82
83 void                    g_socket_listener_set_backlog                   (GSocketListener     *listener,
84                                                                          int                  listen_backlog);
85
86 gboolean                g_socket_listener_add_socket                    (GSocketListener     *listener,
87                                                                          GSocket             *socket,
88                                                                          GObject             *source_object,
89                                                                          GError             **error);
90 gboolean                g_socket_listener_add_address                   (GSocketListener     *listener,
91                                                                          GSocketAddress      *address,
92                                                                          GSocketType          type,
93                                                                          GSocketProtocol      protocol,
94                                                                          GObject             *source_object,
95                                                                          GSocketAddress     **effective_address,
96                                                                          GError             **error);
97 gboolean                g_socket_listener_add_inet_port                 (GSocketListener     *listener,
98                                                                          guint16              port,
99                                                                          GObject             *source_object,
100                                                                          GError             **error);
101 guint16                 g_socket_listener_add_any_inet_port             (GSocketListener     *listener,
102                                                                          GObject             *source_object,
103                                                                          GError             **error);
104
105 GSocket *               g_socket_listener_accept_socket                 (GSocketListener      *listener,
106                                                                          GObject             **source_object,
107                                                                          GCancellable         *cancellable,
108                                                                          GError              **error);
109 void                    g_socket_listener_accept_socket_async           (GSocketListener      *listener,
110                                                                          GCancellable         *cancellable,
111                                                                          GAsyncReadyCallback   callback,
112                                                                          gpointer              user_data);
113 GSocket *               g_socket_listener_accept_socket_finish          (GSocketListener      *listener,
114                                                                          GAsyncResult         *result,
115                                                                          GObject             **source_object,
116                                                                          GError              **error);
117
118
119 GSocketConnection *     g_socket_listener_accept                        (GSocketListener      *listener,
120                                                                          GObject             **source_object,
121                                                                          GCancellable         *cancellable,
122                                                                          GError              **error);
123
124 void                    g_socket_listener_accept_async                  (GSocketListener      *listener,
125                                                                          GCancellable         *cancellable,
126                                                                          GAsyncReadyCallback   callback,
127                                                                          gpointer              user_data);
128
129 GSocketConnection *     g_socket_listener_accept_finish                 (GSocketListener      *listener,
130                                                                          GAsyncResult         *result,
131                                                                          GObject             **source_object,
132                                                                          GError              **error);
133
134 void                    g_socket_listener_close                         (GSocketListener      *listener);
135
136 G_END_DECLS
137
138 #endif /* __G_SOCKET_LISTENER_H__ */