2 * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
3 * Copyright © 2009 Codethink Limited
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.1 of the License, or (at your option) any later version.
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.
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/>.
18 * Authors: Christian Kellner <gicmo@gnome.org>
19 * Samuel Cormier-Iijima <sciyoshi@gmail.com>
20 * Ryan Lortie <desrt@desrt.ca>
23 #ifndef __G_SOCKET_H__
24 #define __G_SOCKET_H__
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
30 #include <gio/giotypes.h>
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), \
41 #define G_IS_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
43 #define G_SOCKET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
44 G_TYPE_SOCKET, GSocketClass))
46 typedef struct _GSocketPrivate GSocketPrivate
;
47 typedef struct _GSocketClass GSocketClass
;
51 GObjectClass parent_class
;
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);
70 GObject parent_instance
;
75 GType
g_socket_get_type (void) G_GNUC_CONST
;
77 GSocket
* g_socket_new (GSocketFamily family
,
79 GSocketProtocol protocol
,
82 GSocket
* g_socket_new_from_fd (gint fd
,
85 int g_socket_get_fd (GSocket
*socket
);
87 GSocketFamily
g_socket_get_family (GSocket
*socket
);
89 GSocketType
g_socket_get_socket_type (GSocket
*socket
);
91 GSocketProtocol
g_socket_get_protocol (GSocket
*socket
);
93 GSocketAddress
* g_socket_get_local_address (GSocket
*socket
,
96 GSocketAddress
* g_socket_get_remote_address (GSocket
*socket
,
99 void g_socket_set_blocking (GSocket
*socket
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
148 GLIB_AVAILABLE_IN_2_32
149 gboolean
g_socket_join_multicast_group (GSocket
*socket
,
151 gboolean source_specific
,
154 GLIB_AVAILABLE_IN_2_32
155 gboolean
g_socket_leave_multicast_group (GSocket
*socket
,
157 gboolean source_specific
,
160 GLIB_AVAILABLE_IN_2_56
161 gboolean
g_socket_join_multicast_group_ssm (GSocket
*socket
,
163 GInetAddress
*source_specific
,
166 GLIB_AVAILABLE_IN_2_56
167 gboolean
g_socket_leave_multicast_group_ssm (GSocket
*socket
,
169 GInetAddress
*source_specific
,
172 GLIB_AVAILABLE_IN_ALL
173 gboolean
g_socket_connect (GSocket
*socket
,
174 GSocketAddress
*address
,
175 GCancellable
*cancellable
,
177 GLIB_AVAILABLE_IN_ALL
178 gboolean
g_socket_check_connect_result (GSocket
*socket
,
181 GLIB_AVAILABLE_IN_ALL
182 gssize
g_socket_get_available_bytes (GSocket
*socket
);
184 GLIB_AVAILABLE_IN_ALL
185 GIOCondition
g_socket_condition_check (GSocket
*socket
,
186 GIOCondition condition
);
187 GLIB_AVAILABLE_IN_ALL
188 gboolean
g_socket_condition_wait (GSocket
*socket
,
189 GIOCondition condition
,
190 GCancellable
*cancellable
,
192 GLIB_AVAILABLE_IN_2_32
193 gboolean
g_socket_condition_timed_wait (GSocket
*socket
,
194 GIOCondition condition
,
196 GCancellable
*cancellable
,
198 GLIB_AVAILABLE_IN_ALL
199 GSocket
* g_socket_accept (GSocket
*socket
,
200 GCancellable
*cancellable
,
202 GLIB_AVAILABLE_IN_ALL
203 gboolean
g_socket_listen (GSocket
*socket
,
205 GLIB_AVAILABLE_IN_ALL
206 gssize
g_socket_receive (GSocket
*socket
,
209 GCancellable
*cancellable
,
211 GLIB_AVAILABLE_IN_ALL
212 gssize
g_socket_receive_from (GSocket
*socket
,
213 GSocketAddress
**address
,
216 GCancellable
*cancellable
,
218 GLIB_AVAILABLE_IN_ALL
219 gssize
g_socket_send (GSocket
*socket
,
222 GCancellable
*cancellable
,
224 GLIB_AVAILABLE_IN_ALL
225 gssize
g_socket_send_to (GSocket
*socket
,
226 GSocketAddress
*address
,
229 GCancellable
*cancellable
,
231 GLIB_AVAILABLE_IN_ALL
232 gssize
g_socket_receive_message (GSocket
*socket
,
233 GSocketAddress
**address
,
234 GInputVector
*vectors
,
236 GSocketControlMessage
***messages
,
239 GCancellable
*cancellable
,
241 GLIB_AVAILABLE_IN_ALL
242 gssize
g_socket_send_message (GSocket
*socket
,
243 GSocketAddress
*address
,
244 GOutputVector
*vectors
,
246 GSocketControlMessage
**messages
,
249 GCancellable
*cancellable
,
252 GLIB_AVAILABLE_IN_2_48
253 gint
g_socket_receive_messages (GSocket
*socket
,
254 GInputMessage
*messages
,
257 GCancellable
*cancellable
,
259 GLIB_AVAILABLE_IN_2_44
260 gint
g_socket_send_messages (GSocket
*socket
,
261 GOutputMessage
*messages
,
264 GCancellable
*cancellable
,
267 GLIB_AVAILABLE_IN_ALL
268 gboolean
g_socket_close (GSocket
*socket
,
270 GLIB_AVAILABLE_IN_ALL
271 gboolean
g_socket_shutdown (GSocket
*socket
,
272 gboolean shutdown_read
,
273 gboolean shutdown_write
,
275 GLIB_AVAILABLE_IN_ALL
276 gboolean
g_socket_is_closed (GSocket
*socket
);
277 GLIB_AVAILABLE_IN_ALL
278 GSource
* g_socket_create_source (GSocket
*socket
,
279 GIOCondition condition
,
280 GCancellable
*cancellable
);
281 GLIB_AVAILABLE_IN_ALL
282 gboolean
g_socket_speaks_ipv4 (GSocket
*socket
);
283 GLIB_AVAILABLE_IN_ALL
284 GCredentials
*g_socket_get_credentials (GSocket
*socket
,
287 GLIB_AVAILABLE_IN_ALL
288 gssize
g_socket_receive_with_blocking (GSocket
*socket
,
292 GCancellable
*cancellable
,
294 GLIB_AVAILABLE_IN_ALL
295 gssize
g_socket_send_with_blocking (GSocket
*socket
,
299 GCancellable
*cancellable
,
302 GLIB_AVAILABLE_IN_2_36
303 gboolean
g_socket_get_option (GSocket
*socket
,
308 GLIB_AVAILABLE_IN_2_36
309 gboolean
g_socket_set_option (GSocket
*socket
,
317 #endif /* __G_SOCKET_H__ */