various: add GLIB_AVAILABLE_IN_ALL everywhere else
[platform/upstream/glib.git] / gio / gsocket.h
1 /*
2  * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
3  * Copyright © 2009 Codethink Limited
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Authors: Christian Kellner <gicmo@gnome.org>
21  *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
22  *          Ryan Lortie <desrt@desrt.ca>
23  */
24
25 #ifndef __G_SOCKET_H__
26 #define __G_SOCKET_H__
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 #include <gio/giotypes.h>
33
34 G_BEGIN_DECLS
35
36 #define G_TYPE_SOCKET                                       (g_socket_get_type ())
37 #define G_SOCKET(inst)                                      (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
38                                                              G_TYPE_SOCKET, GSocket))
39 #define G_SOCKET_CLASS(class)                               (G_TYPE_CHECK_CLASS_CAST ((class),                       \
40                                                              G_TYPE_SOCKET, GSocketClass))
41 #define G_IS_SOCKET(inst)                                   (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
42                                                              G_TYPE_SOCKET))
43 #define G_IS_SOCKET_CLASS(class)                            (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
44                                                              G_TYPE_SOCKET))
45 #define G_SOCKET_GET_CLASS(inst)                            (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
46                                                              G_TYPE_SOCKET, GSocketClass))
47
48 typedef struct _GSocketPrivate                              GSocketPrivate;
49 typedef struct _GSocketClass                                GSocketClass;
50
51 struct _GSocketClass
52 {
53   GObjectClass parent_class;
54
55   /*< private >*/
56
57   /* Padding for future expansion */
58   void (*_g_reserved1) (void);
59   void (*_g_reserved2) (void);
60   void (*_g_reserved3) (void);
61   void (*_g_reserved4) (void);
62   void (*_g_reserved5) (void);
63   void (*_g_reserved6) (void);
64   void (*_g_reserved7) (void);
65   void (*_g_reserved8) (void);
66   void (*_g_reserved9) (void);
67   void (*_g_reserved10) (void);
68 };
69
70 struct _GSocket
71 {
72   GObject parent_instance;
73   GSocketPrivate *priv;
74 };
75
76 GLIB_AVAILABLE_IN_ALL
77 GType                  g_socket_get_type                (void) G_GNUC_CONST;
78 GLIB_AVAILABLE_IN_ALL
79 GSocket *              g_socket_new                     (GSocketFamily            family,
80                                                          GSocketType              type,
81                                                          GSocketProtocol          protocol,
82                                                          GError                 **error);
83 GLIB_AVAILABLE_IN_ALL
84 GSocket *              g_socket_new_from_fd             (gint                     fd,
85                                                          GError                 **error);
86 GLIB_AVAILABLE_IN_ALL
87 int                    g_socket_get_fd                  (GSocket                 *socket);
88 GLIB_AVAILABLE_IN_ALL
89 GSocketFamily          g_socket_get_family              (GSocket                 *socket);
90 GLIB_AVAILABLE_IN_ALL
91 GSocketType            g_socket_get_socket_type         (GSocket                 *socket);
92 GLIB_AVAILABLE_IN_ALL
93 GSocketProtocol        g_socket_get_protocol            (GSocket                 *socket);
94 GLIB_AVAILABLE_IN_ALL
95 GSocketAddress *       g_socket_get_local_address       (GSocket                 *socket,
96                                                          GError                 **error);
97 GLIB_AVAILABLE_IN_ALL
98 GSocketAddress *       g_socket_get_remote_address      (GSocket                 *socket,
99                                                          GError                 **error);
100 GLIB_AVAILABLE_IN_ALL
101 void                   g_socket_set_blocking            (GSocket                 *socket,
102                                                          gboolean                 blocking);
103 GLIB_AVAILABLE_IN_ALL
104 gboolean               g_socket_get_blocking            (GSocket                 *socket);
105 GLIB_AVAILABLE_IN_ALL
106 void                   g_socket_set_keepalive           (GSocket                 *socket,
107                                                          gboolean                 keepalive);
108 GLIB_AVAILABLE_IN_ALL
109 gboolean               g_socket_get_keepalive           (GSocket                 *socket);
110 GLIB_AVAILABLE_IN_ALL
111 gint                   g_socket_get_listen_backlog      (GSocket                 *socket);
112 GLIB_AVAILABLE_IN_ALL
113 void                   g_socket_set_listen_backlog      (GSocket                 *socket,
114                                                          gint                     backlog);
115 GLIB_AVAILABLE_IN_ALL
116 guint                  g_socket_get_timeout             (GSocket                 *socket);
117 GLIB_AVAILABLE_IN_ALL
118 void                   g_socket_set_timeout             (GSocket                 *socket,
119                                                          guint                    timeout);
120
121 GLIB_AVAILABLE_IN_2_32
122 guint                  g_socket_get_ttl                 (GSocket                 *socket);
123 GLIB_AVAILABLE_IN_2_32
124 void                   g_socket_set_ttl                 (GSocket                 *socket,
125                                                          guint                    ttl);
126
127 GLIB_AVAILABLE_IN_2_32
128 gboolean               g_socket_get_broadcast           (GSocket                 *socket);
129 GLIB_AVAILABLE_IN_2_32
130 void                   g_socket_set_broadcast           (GSocket                 *socket,
131                                                          gboolean                 broadcast);
132
133 GLIB_AVAILABLE_IN_2_32
134 gboolean               g_socket_get_multicast_loopback  (GSocket                 *socket);
135 GLIB_AVAILABLE_IN_2_32
136 void                   g_socket_set_multicast_loopback  (GSocket                 *socket,
137                                                          gboolean                 loopback);
138 GLIB_AVAILABLE_IN_2_32
139 guint                  g_socket_get_multicast_ttl       (GSocket                 *socket);
140 GLIB_AVAILABLE_IN_2_32
141 void                   g_socket_set_multicast_ttl       (GSocket                 *socket,
142                                                          guint                    ttl);
143 GLIB_AVAILABLE_IN_ALL
144 gboolean               g_socket_is_connected            (GSocket                 *socket);
145 GLIB_AVAILABLE_IN_ALL
146 gboolean               g_socket_bind                    (GSocket                 *socket,
147                                                          GSocketAddress          *address,
148                                                          gboolean                 allow_reuse,
149                                                          GError                 **error);
150 GLIB_AVAILABLE_IN_2_32
151 gboolean               g_socket_join_multicast_group    (GSocket                 *socket,
152                                                          GInetAddress            *group,
153                                                          gboolean                 source_specific,
154                                                          const gchar             *iface,
155                                                          GError                 **error);
156 GLIB_AVAILABLE_IN_2_32
157 gboolean               g_socket_leave_multicast_group   (GSocket                 *socket,
158                                                          GInetAddress            *group,
159                                                          gboolean                 source_specific,
160                                                          const gchar             *iface,
161                                                          GError                 **error);
162 GLIB_AVAILABLE_IN_ALL
163 gboolean               g_socket_connect                 (GSocket                 *socket,
164                                                          GSocketAddress          *address,
165                                                          GCancellable            *cancellable,
166                                                          GError                 **error);
167 GLIB_AVAILABLE_IN_ALL
168 gboolean               g_socket_check_connect_result    (GSocket                 *socket,
169                                                          GError                 **error);
170
171 GLIB_AVAILABLE_IN_ALL
172 gssize                 g_socket_get_available_bytes     (GSocket                 *socket);
173
174 GLIB_AVAILABLE_IN_ALL
175 GIOCondition           g_socket_condition_check         (GSocket                 *socket,
176                                                          GIOCondition             condition);
177 GLIB_AVAILABLE_IN_ALL
178 gboolean               g_socket_condition_wait          (GSocket                 *socket,
179                                                          GIOCondition             condition,
180                                                          GCancellable            *cancellable,
181                                                          GError                 **error);
182 GLIB_AVAILABLE_IN_2_32
183 gboolean               g_socket_condition_timed_wait    (GSocket                 *socket,
184                                                          GIOCondition             condition,
185                                                          gint64                   timeout,
186                                                          GCancellable            *cancellable,
187                                                          GError                 **error);
188 GLIB_AVAILABLE_IN_ALL
189 GSocket *              g_socket_accept                  (GSocket                 *socket,
190                                                          GCancellable            *cancellable,
191                                                          GError                 **error);
192 GLIB_AVAILABLE_IN_ALL
193 gboolean               g_socket_listen                  (GSocket                 *socket,
194                                                          GError                 **error);
195 GLIB_AVAILABLE_IN_ALL
196 gssize                 g_socket_receive                 (GSocket                 *socket,
197                                                          gchar                   *buffer,
198                                                          gsize                    size,
199                                                          GCancellable            *cancellable,
200                                                          GError                 **error);
201 GLIB_AVAILABLE_IN_ALL
202 gssize                 g_socket_receive_from            (GSocket                 *socket,
203                                                          GSocketAddress         **address,
204                                                          gchar                   *buffer,
205                                                          gsize                    size,
206                                                          GCancellable            *cancellable,
207                                                          GError                 **error);
208 GLIB_AVAILABLE_IN_ALL
209 gssize                 g_socket_send                    (GSocket                 *socket,
210                                                          const gchar             *buffer,
211                                                          gsize                    size,
212                                                          GCancellable            *cancellable,
213                                                          GError                 **error);
214 GLIB_AVAILABLE_IN_ALL
215 gssize                 g_socket_send_to                 (GSocket                 *socket,
216                                                          GSocketAddress          *address,
217                                                          const gchar             *buffer,
218                                                          gsize                    size,
219                                                          GCancellable            *cancellable,
220                                                          GError                 **error);
221 GLIB_AVAILABLE_IN_ALL
222 gssize                 g_socket_receive_message         (GSocket                 *socket,
223                                                          GSocketAddress         **address,
224                                                          GInputVector            *vectors,
225                                                          gint                     num_vectors,
226                                                          GSocketControlMessage ***messages,
227                                                          gint                    *num_messages,
228                                                          gint                    *flags,
229                                                          GCancellable            *cancellable,
230                                                          GError                 **error);
231 GLIB_AVAILABLE_IN_ALL
232 gssize                 g_socket_send_message            (GSocket                 *socket,
233                                                          GSocketAddress          *address,
234                                                          GOutputVector           *vectors,
235                                                          gint                     num_vectors,
236                                                          GSocketControlMessage  **messages,
237                                                          gint                     num_messages,
238                                                          gint                     flags,
239                                                          GCancellable            *cancellable,
240                                                          GError                 **error);
241 GLIB_AVAILABLE_IN_ALL
242 gboolean               g_socket_close                   (GSocket                 *socket,
243                                                          GError                 **error);
244 GLIB_AVAILABLE_IN_ALL
245 gboolean               g_socket_shutdown                (GSocket                 *socket,
246                                                          gboolean                 shutdown_read,
247                                                          gboolean                 shutdown_write,
248                                                          GError                 **error);
249 GLIB_AVAILABLE_IN_ALL
250 gboolean               g_socket_is_closed               (GSocket                 *socket);
251 GLIB_AVAILABLE_IN_ALL
252 GSource *              g_socket_create_source           (GSocket                 *socket,
253                                                          GIOCondition             condition,
254                                                          GCancellable            *cancellable);
255 GLIB_AVAILABLE_IN_ALL
256 gboolean               g_socket_speaks_ipv4             (GSocket                 *socket);
257 GLIB_AVAILABLE_IN_ALL
258 GCredentials          *g_socket_get_credentials         (GSocket                 *socket,
259                                                          GError                 **error);
260
261 GLIB_AVAILABLE_IN_ALL
262 gssize                 g_socket_receive_with_blocking   (GSocket                 *socket,
263                                                          gchar                   *buffer,
264                                                          gsize                    size,
265                                                          gboolean                 blocking,
266                                                          GCancellable            *cancellable,
267                                                          GError                 **error);
268 GLIB_AVAILABLE_IN_ALL
269 gssize                 g_socket_send_with_blocking      (GSocket                 *socket,
270                                                          const gchar             *buffer,
271                                                          gsize                    size,
272                                                          gboolean                 blocking,
273                                                          GCancellable            *cancellable,
274                                                          GError                 **error);
275
276 GLIB_AVAILABLE_IN_2_36
277 gboolean               g_socket_get_option              (GSocket                 *socket,
278                                                          gint                     level,
279                                                          gint                     optname,
280                                                          gint                    *value,
281                                                          GError                 **error);
282 GLIB_AVAILABLE_IN_2_36
283 gboolean               g_socket_set_option              (GSocket                 *socket,
284                                                          gint                     level,
285                                                          gint                     optname,
286                                                          gint                     value,
287                                                          GError                 **error);
288
289 G_END_DECLS
290
291 #endif /* __G_SOCKET_H__ */