gio/tests/file: skip the file monitor tests if using GPollFileMonitor
[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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26 #error "Only <gio/gio.h> can be included directly."
27 #endif
28
29 #ifndef __G_SOCKET_H__
30 #define __G_SOCKET_H__
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 GType                  g_socket_get_type                (void) G_GNUC_CONST;
77 GSocket *              g_socket_new                     (GSocketFamily            family,
78                                                          GSocketType              type,
79                                                          GSocketProtocol          protocol,
80                                                          GError                 **error);
81 GSocket *              g_socket_new_from_fd             (gint                     fd,
82                                                          GError                 **error);
83 int                    g_socket_get_fd                  (GSocket                 *socket);
84 GSocketFamily          g_socket_get_family              (GSocket                 *socket);
85 GSocketType            g_socket_get_socket_type         (GSocket                 *socket);
86 GSocketProtocol        g_socket_get_protocol            (GSocket                 *socket);
87 GSocketAddress *       g_socket_get_local_address       (GSocket                 *socket,
88                                                          GError                 **error);
89 GSocketAddress *       g_socket_get_remote_address      (GSocket                 *socket,
90                                                          GError                 **error);
91 void                   g_socket_set_blocking            (GSocket                 *socket,
92                                                          gboolean                 blocking);
93 gboolean               g_socket_get_blocking            (GSocket                 *socket);
94 void                   g_socket_set_keepalive           (GSocket                 *socket,
95                                                          gboolean                 keepalive);
96 gboolean               g_socket_get_keepalive           (GSocket                 *socket);
97 gint                   g_socket_get_listen_backlog      (GSocket                 *socket);
98 void                   g_socket_set_listen_backlog      (GSocket                 *socket,
99                                                          gint                     backlog);
100 guint                  g_socket_get_timeout             (GSocket                 *socket);
101 void                   g_socket_set_timeout             (GSocket                 *socket,
102                                                          guint                    timeout);
103
104 GLIB_AVAILABLE_IN_2_32
105 guint                  g_socket_get_ttl                 (GSocket                 *socket);
106 GLIB_AVAILABLE_IN_2_32
107 void                   g_socket_set_ttl                 (GSocket                 *socket,
108                                                          guint                    ttl);
109
110 GLIB_AVAILABLE_IN_2_32
111 gboolean               g_socket_get_broadcast           (GSocket                 *socket);
112 GLIB_AVAILABLE_IN_2_32
113 void                   g_socket_set_broadcast           (GSocket                 *socket,
114                                                          gboolean                 broadcast);
115
116 GLIB_AVAILABLE_IN_2_32
117 gboolean               g_socket_get_multicast_loopback  (GSocket                 *socket);
118 GLIB_AVAILABLE_IN_2_32
119 void                   g_socket_set_multicast_loopback  (GSocket                 *socket,
120                                                          gboolean                 loopback);
121 GLIB_AVAILABLE_IN_2_32
122 guint                  g_socket_get_multicast_ttl       (GSocket                 *socket);
123 GLIB_AVAILABLE_IN_2_32
124 void                   g_socket_set_multicast_ttl       (GSocket                 *socket,
125                                                          guint                    ttl);
126 gboolean               g_socket_is_connected            (GSocket                 *socket);
127 gboolean               g_socket_bind                    (GSocket                 *socket,
128                                                          GSocketAddress          *address,
129                                                          gboolean                 allow_reuse,
130                                                          GError                 **error);
131 GLIB_AVAILABLE_IN_2_32
132 gboolean               g_socket_join_multicast_group    (GSocket                 *socket,
133                                                          GInetAddress            *group,
134                                                          gboolean                 source_specific,
135                                                          const gchar             *iface,
136                                                          GError                 **error);
137 GLIB_AVAILABLE_IN_2_32
138 gboolean               g_socket_leave_multicast_group   (GSocket                 *socket,
139                                                          GInetAddress            *group,
140                                                          gboolean                 source_specific,
141                                                          const gchar             *iface,
142                                                          GError                 **error);
143 gboolean               g_socket_connect                 (GSocket                 *socket,
144                                                          GSocketAddress          *address,
145                                                          GCancellable            *cancellable,
146                                                          GError                 **error);
147 gboolean               g_socket_check_connect_result    (GSocket                 *socket,
148                                                          GError                 **error);
149
150 gssize                 g_socket_get_available_bytes     (GSocket                 *socket);
151
152 GIOCondition           g_socket_condition_check         (GSocket                 *socket,
153                                                          GIOCondition             condition);
154 gboolean               g_socket_condition_wait          (GSocket                 *socket,
155                                                          GIOCondition             condition,
156                                                          GCancellable            *cancellable,
157                                                          GError                 **error);
158 GLIB_AVAILABLE_IN_2_32
159 gboolean               g_socket_condition_timed_wait    (GSocket                 *socket,
160                                                          GIOCondition             condition,
161                                                          gint64                   timeout,
162                                                          GCancellable            *cancellable,
163                                                          GError                 **error);
164 GSocket *              g_socket_accept                  (GSocket                 *socket,
165                                                          GCancellable            *cancellable,
166                                                          GError                 **error);
167 gboolean               g_socket_listen                  (GSocket                 *socket,
168                                                          GError                 **error);
169 gssize                 g_socket_receive                 (GSocket                 *socket,
170                                                          gchar                   *buffer,
171                                                          gsize                    size,
172                                                          GCancellable            *cancellable,
173                                                          GError                 **error);
174 gssize                 g_socket_receive_from            (GSocket                 *socket,
175                                                          GSocketAddress         **address,
176                                                          gchar                   *buffer,
177                                                          gsize                    size,
178                                                          GCancellable            *cancellable,
179                                                          GError                 **error);
180 gssize                 g_socket_send                    (GSocket                 *socket,
181                                                          const gchar             *buffer,
182                                                          gsize                    size,
183                                                          GCancellable            *cancellable,
184                                                          GError                 **error);
185 gssize                 g_socket_send_to                 (GSocket                 *socket,
186                                                          GSocketAddress          *address,
187                                                          const gchar             *buffer,
188                                                          gsize                    size,
189                                                          GCancellable            *cancellable,
190                                                          GError                 **error);
191 gssize                 g_socket_receive_message         (GSocket                 *socket,
192                                                          GSocketAddress         **address,
193                                                          GInputVector            *vectors,
194                                                          gint                     num_vectors,
195                                                          GSocketControlMessage ***messages,
196                                                          gint                    *num_messages,
197                                                          gint                    *flags,
198                                                          GCancellable            *cancellable,
199                                                          GError                 **error);
200 gssize                 g_socket_send_message            (GSocket                 *socket,
201                                                          GSocketAddress          *address,
202                                                          GOutputVector           *vectors,
203                                                          gint                     num_vectors,
204                                                          GSocketControlMessage  **messages,
205                                                          gint                     num_messages,
206                                                          gint                     flags,
207                                                          GCancellable            *cancellable,
208                                                          GError                 **error);
209 gboolean               g_socket_close                   (GSocket                 *socket,
210                                                          GError                 **error);
211 gboolean               g_socket_shutdown                (GSocket                 *socket,
212                                                          gboolean                 shutdown_read,
213                                                          gboolean                 shutdown_write,
214                                                          GError                 **error);
215 gboolean               g_socket_is_closed               (GSocket                 *socket);
216 GSource *              g_socket_create_source           (GSocket                 *socket,
217                                                          GIOCondition             condition,
218                                                          GCancellable            *cancellable);
219 gboolean               g_socket_speaks_ipv4             (GSocket                 *socket);
220 GCredentials          *g_socket_get_credentials         (GSocket                 *socket,
221                                                          GError                 **error);
222
223 gssize                 g_socket_receive_with_blocking   (GSocket                 *socket,
224                                                          gchar                   *buffer,
225                                                          gsize                    size,
226                                                          gboolean                 blocking,
227                                                          GCancellable            *cancellable,
228                                                          GError                 **error);
229 gssize                 g_socket_send_with_blocking      (GSocket                 *socket,
230                                                          const gchar             *buffer,
231                                                          gsize                    size,
232                                                          gboolean                 blocking,
233                                                          GCancellable            *cancellable,
234                                                          GError                 **error);
235
236 G_END_DECLS
237
238 #endif /* __G_SOCKET_H__ */