gsocket: Add missing preconditions to g_socket_send_message()
[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, see <http://www.gnu.org/licenses/>.
17  *
18  * Authors: Christian Kellner <gicmo@gnome.org>
19  *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
20  *          Ryan Lortie <desrt@desrt.ca>
21  */
22
23 #ifndef __G_SOCKET_H__
24 #define __G_SOCKET_H__
25
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
28 #endif
29
30 #include <gio/giotypes.h>
31
32 G_BEGIN_DECLS
33
34 #define G_TYPE_SOCKET                                       (g_socket_get_type ())
35 #define G_SOCKET(inst)                                      (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
36                                                              G_TYPE_SOCKET, GSocket))
37 #define G_SOCKET_CLASS(class)                               (G_TYPE_CHECK_CLASS_CAST ((class),                       \
38                                                              G_TYPE_SOCKET, GSocketClass))
39 #define G_IS_SOCKET(inst)                                   (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
40                                                              G_TYPE_SOCKET))
41 #define G_IS_SOCKET_CLASS(class)                            (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
42                                                              G_TYPE_SOCKET))
43 #define G_SOCKET_GET_CLASS(inst)                            (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
44                                                              G_TYPE_SOCKET, GSocketClass))
45
46 typedef struct _GSocketPrivate                              GSocketPrivate;
47 typedef struct _GSocketClass                                GSocketClass;
48
49 struct _GSocketClass
50 {
51   GObjectClass parent_class;
52
53   /*< private >*/
54
55   /* Padding for future expansion */
56   void (*_g_reserved1) (void);
57   void (*_g_reserved2) (void);
58   void (*_g_reserved3) (void);
59   void (*_g_reserved4) (void);
60   void (*_g_reserved5) (void);
61   void (*_g_reserved6) (void);
62   void (*_g_reserved7) (void);
63   void (*_g_reserved8) (void);
64   void (*_g_reserved9) (void);
65   void (*_g_reserved10) (void);
66 };
67
68 struct _GSocket
69 {
70   GObject parent_instance;
71   GSocketPrivate *priv;
72 };
73
74 GLIB_AVAILABLE_IN_ALL
75 GType                  g_socket_get_type                (void) G_GNUC_CONST;
76 GLIB_AVAILABLE_IN_ALL
77 GSocket *              g_socket_new                     (GSocketFamily            family,
78                                                          GSocketType              type,
79                                                          GSocketProtocol          protocol,
80                                                          GError                 **error);
81 GLIB_AVAILABLE_IN_ALL
82 GSocket *              g_socket_new_from_fd             (gint                     fd,
83                                                          GError                 **error);
84 GLIB_AVAILABLE_IN_ALL
85 int                    g_socket_get_fd                  (GSocket                 *socket);
86 GLIB_AVAILABLE_IN_ALL
87 GSocketFamily          g_socket_get_family              (GSocket                 *socket);
88 GLIB_AVAILABLE_IN_ALL
89 GSocketType            g_socket_get_socket_type         (GSocket                 *socket);
90 GLIB_AVAILABLE_IN_ALL
91 GSocketProtocol        g_socket_get_protocol            (GSocket                 *socket);
92 GLIB_AVAILABLE_IN_ALL
93 GSocketAddress *       g_socket_get_local_address       (GSocket                 *socket,
94                                                          GError                 **error);
95 GLIB_AVAILABLE_IN_ALL
96 GSocketAddress *       g_socket_get_remote_address      (GSocket                 *socket,
97                                                          GError                 **error);
98 GLIB_AVAILABLE_IN_ALL
99 void                   g_socket_set_blocking            (GSocket                 *socket,
100                                                          gboolean                 blocking);
101 GLIB_AVAILABLE_IN_ALL
102 gboolean               g_socket_get_blocking            (GSocket                 *socket);
103 GLIB_AVAILABLE_IN_ALL
104 void                   g_socket_set_keepalive           (GSocket                 *socket,
105                                                          gboolean                 keepalive);
106 GLIB_AVAILABLE_IN_ALL
107 gboolean               g_socket_get_keepalive           (GSocket                 *socket);
108 GLIB_AVAILABLE_IN_ALL
109 gint                   g_socket_get_listen_backlog      (GSocket                 *socket);
110 GLIB_AVAILABLE_IN_ALL
111 void                   g_socket_set_listen_backlog      (GSocket                 *socket,
112                                                          gint                     backlog);
113 GLIB_AVAILABLE_IN_ALL
114 guint                  g_socket_get_timeout             (GSocket                 *socket);
115 GLIB_AVAILABLE_IN_ALL
116 void                   g_socket_set_timeout             (GSocket                 *socket,
117                                                          guint                    timeout);
118
119 GLIB_AVAILABLE_IN_2_32
120 guint                  g_socket_get_ttl                 (GSocket                 *socket);
121 GLIB_AVAILABLE_IN_2_32
122 void                   g_socket_set_ttl                 (GSocket                 *socket,
123                                                          guint                    ttl);
124
125 GLIB_AVAILABLE_IN_2_32
126 gboolean               g_socket_get_broadcast           (GSocket                 *socket);
127 GLIB_AVAILABLE_IN_2_32
128 void                   g_socket_set_broadcast           (GSocket                 *socket,
129                                                          gboolean                 broadcast);
130
131 GLIB_AVAILABLE_IN_2_32
132 gboolean               g_socket_get_multicast_loopback  (GSocket                 *socket);
133 GLIB_AVAILABLE_IN_2_32
134 void                   g_socket_set_multicast_loopback  (GSocket                 *socket,
135                                                          gboolean                 loopback);
136 GLIB_AVAILABLE_IN_2_32
137 guint                  g_socket_get_multicast_ttl       (GSocket                 *socket);
138 GLIB_AVAILABLE_IN_2_32
139 void                   g_socket_set_multicast_ttl       (GSocket                 *socket,
140                                                          guint                    ttl);
141 GLIB_AVAILABLE_IN_ALL
142 gboolean               g_socket_is_connected            (GSocket                 *socket);
143 GLIB_AVAILABLE_IN_ALL
144 gboolean               g_socket_bind                    (GSocket                 *socket,
145                                                          GSocketAddress          *address,
146                                                          gboolean                 allow_reuse,
147                                                          GError                 **error);
148 GLIB_AVAILABLE_IN_2_32
149 gboolean               g_socket_join_multicast_group    (GSocket                 *socket,
150                                                          GInetAddress            *group,
151                                                          gboolean                 source_specific,
152                                                          const gchar             *iface,
153                                                          GError                 **error);
154 GLIB_AVAILABLE_IN_2_32
155 gboolean               g_socket_leave_multicast_group   (GSocket                 *socket,
156                                                          GInetAddress            *group,
157                                                          gboolean                 source_specific,
158                                                          const gchar             *iface,
159                                                          GError                 **error);
160 GLIB_AVAILABLE_IN_ALL
161 gboolean               g_socket_connect                 (GSocket                 *socket,
162                                                          GSocketAddress          *address,
163                                                          GCancellable            *cancellable,
164                                                          GError                 **error);
165 GLIB_AVAILABLE_IN_ALL
166 gboolean               g_socket_check_connect_result    (GSocket                 *socket,
167                                                          GError                 **error);
168
169 GLIB_AVAILABLE_IN_ALL
170 gssize                 g_socket_get_available_bytes     (GSocket                 *socket);
171
172 GLIB_AVAILABLE_IN_ALL
173 GIOCondition           g_socket_condition_check         (GSocket                 *socket,
174                                                          GIOCondition             condition);
175 GLIB_AVAILABLE_IN_ALL
176 gboolean               g_socket_condition_wait          (GSocket                 *socket,
177                                                          GIOCondition             condition,
178                                                          GCancellable            *cancellable,
179                                                          GError                 **error);
180 GLIB_AVAILABLE_IN_2_32
181 gboolean               g_socket_condition_timed_wait    (GSocket                 *socket,
182                                                          GIOCondition             condition,
183                                                          gint64                   timeout,
184                                                          GCancellable            *cancellable,
185                                                          GError                 **error);
186 GLIB_AVAILABLE_IN_ALL
187 GSocket *              g_socket_accept                  (GSocket                 *socket,
188                                                          GCancellable            *cancellable,
189                                                          GError                 **error);
190 GLIB_AVAILABLE_IN_ALL
191 gboolean               g_socket_listen                  (GSocket                 *socket,
192                                                          GError                 **error);
193 GLIB_AVAILABLE_IN_ALL
194 gssize                 g_socket_receive                 (GSocket                 *socket,
195                                                          gchar                   *buffer,
196                                                          gsize                    size,
197                                                          GCancellable            *cancellable,
198                                                          GError                 **error);
199 GLIB_AVAILABLE_IN_ALL
200 gssize                 g_socket_receive_from            (GSocket                 *socket,
201                                                          GSocketAddress         **address,
202                                                          gchar                   *buffer,
203                                                          gsize                    size,
204                                                          GCancellable            *cancellable,
205                                                          GError                 **error);
206 GLIB_AVAILABLE_IN_ALL
207 gssize                 g_socket_send                    (GSocket                 *socket,
208                                                          const gchar             *buffer,
209                                                          gsize                    size,
210                                                          GCancellable            *cancellable,
211                                                          GError                 **error);
212 GLIB_AVAILABLE_IN_ALL
213 gssize                 g_socket_send_to                 (GSocket                 *socket,
214                                                          GSocketAddress          *address,
215                                                          const gchar             *buffer,
216                                                          gsize                    size,
217                                                          GCancellable            *cancellable,
218                                                          GError                 **error);
219 GLIB_AVAILABLE_IN_ALL
220 gssize                 g_socket_receive_message         (GSocket                 *socket,
221                                                          GSocketAddress         **address,
222                                                          GInputVector            *vectors,
223                                                          gint                     num_vectors,
224                                                          GSocketControlMessage ***messages,
225                                                          gint                    *num_messages,
226                                                          gint                    *flags,
227                                                          GCancellable            *cancellable,
228                                                          GError                 **error);
229 GLIB_AVAILABLE_IN_ALL
230 gssize                 g_socket_send_message            (GSocket                 *socket,
231                                                          GSocketAddress          *address,
232                                                          GOutputVector           *vectors,
233                                                          gint                     num_vectors,
234                                                          GSocketControlMessage  **messages,
235                                                          gint                     num_messages,
236                                                          gint                     flags,
237                                                          GCancellable            *cancellable,
238                                                          GError                 **error);
239 GLIB_AVAILABLE_IN_ALL
240 gboolean               g_socket_close                   (GSocket                 *socket,
241                                                          GError                 **error);
242 GLIB_AVAILABLE_IN_ALL
243 gboolean               g_socket_shutdown                (GSocket                 *socket,
244                                                          gboolean                 shutdown_read,
245                                                          gboolean                 shutdown_write,
246                                                          GError                 **error);
247 GLIB_AVAILABLE_IN_ALL
248 gboolean               g_socket_is_closed               (GSocket                 *socket);
249 GLIB_AVAILABLE_IN_ALL
250 GSource *              g_socket_create_source           (GSocket                 *socket,
251                                                          GIOCondition             condition,
252                                                          GCancellable            *cancellable);
253 GLIB_AVAILABLE_IN_ALL
254 gboolean               g_socket_speaks_ipv4             (GSocket                 *socket);
255 GLIB_AVAILABLE_IN_ALL
256 GCredentials          *g_socket_get_credentials         (GSocket                 *socket,
257                                                          GError                 **error);
258
259 GLIB_AVAILABLE_IN_ALL
260 gssize                 g_socket_receive_with_blocking   (GSocket                 *socket,
261                                                          gchar                   *buffer,
262                                                          gsize                    size,
263                                                          gboolean                 blocking,
264                                                          GCancellable            *cancellable,
265                                                          GError                 **error);
266 GLIB_AVAILABLE_IN_ALL
267 gssize                 g_socket_send_with_blocking      (GSocket                 *socket,
268                                                          const gchar             *buffer,
269                                                          gsize                    size,
270                                                          gboolean                 blocking,
271                                                          GCancellable            *cancellable,
272                                                          GError                 **error);
273
274 GLIB_AVAILABLE_IN_2_36
275 gboolean               g_socket_get_option              (GSocket                 *socket,
276                                                          gint                     level,
277                                                          gint                     optname,
278                                                          gint                    *value,
279                                                          GError                 **error);
280 GLIB_AVAILABLE_IN_2_36
281 gboolean               g_socket_set_option              (GSocket                 *socket,
282                                                          gint                     level,
283                                                          gint                     optname,
284                                                          gint                     value,
285                                                          GError                 **error);
286
287 G_END_DECLS
288
289 #endif /* __G_SOCKET_H__ */