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 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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Christian Kellner <gicmo@gnome.org>
21 * Samuel Cormier-Iijima <sciyoshi@gmail.com>
22 * Ryan Lortie <desrt@desrt.ca>
25 #ifndef __G_SOCKET_H__
26 #define __G_SOCKET_H__
28 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
29 #error "Only <gio/gio.h> can be included directly."
32 #include <gio/giotypes.h>
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), \
43 #define G_IS_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
45 #define G_SOCKET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
46 G_TYPE_SOCKET, GSocketClass))
48 typedef struct _GSocketPrivate GSocketPrivate;
49 typedef struct _GSocketClass GSocketClass;
53 GObjectClass parent_class;
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);
72 GObject parent_instance;
77 GType g_socket_get_type (void) G_GNUC_CONST;
79 GSocket * g_socket_new (GSocketFamily family,
81 GSocketProtocol protocol,
84 GSocket * g_socket_new_from_fd (gint fd,
87 int g_socket_get_fd (GSocket *socket);
89 GSocketFamily g_socket_get_family (GSocket *socket);
91 GSocketType g_socket_get_socket_type (GSocket *socket);
93 GSocketProtocol g_socket_get_protocol (GSocket *socket);
95 GSocketAddress * g_socket_get_local_address (GSocket *socket,
98 GSocketAddress * g_socket_get_remote_address (GSocket *socket,
100 GLIB_AVAILABLE_IN_ALL
101 void g_socket_set_blocking (GSocket *socket,
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,
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,
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,
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,
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,
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,
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,
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,
150 GLIB_AVAILABLE_IN_2_32
151 gboolean g_socket_join_multicast_group (GSocket *socket,
153 gboolean source_specific,
156 GLIB_AVAILABLE_IN_2_32
157 gboolean g_socket_leave_multicast_group (GSocket *socket,
159 gboolean source_specific,
162 GLIB_AVAILABLE_IN_ALL
163 gboolean g_socket_connect (GSocket *socket,
164 GSocketAddress *address,
165 GCancellable *cancellable,
167 GLIB_AVAILABLE_IN_ALL
168 gboolean g_socket_check_connect_result (GSocket *socket,
171 GLIB_AVAILABLE_IN_ALL
172 gssize g_socket_get_available_bytes (GSocket *socket);
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,
182 GLIB_AVAILABLE_IN_2_32
183 gboolean g_socket_condition_timed_wait (GSocket *socket,
184 GIOCondition condition,
186 GCancellable *cancellable,
188 GLIB_AVAILABLE_IN_ALL
189 GSocket * g_socket_accept (GSocket *socket,
190 GCancellable *cancellable,
192 GLIB_AVAILABLE_IN_ALL
193 gboolean g_socket_listen (GSocket *socket,
195 GLIB_AVAILABLE_IN_ALL
196 gssize g_socket_receive (GSocket *socket,
199 GCancellable *cancellable,
201 GLIB_AVAILABLE_IN_ALL
202 gssize g_socket_receive_from (GSocket *socket,
203 GSocketAddress **address,
206 GCancellable *cancellable,
208 GLIB_AVAILABLE_IN_ALL
209 gssize g_socket_send (GSocket *socket,
212 GCancellable *cancellable,
214 GLIB_AVAILABLE_IN_ALL
215 gssize g_socket_send_to (GSocket *socket,
216 GSocketAddress *address,
219 GCancellable *cancellable,
221 GLIB_AVAILABLE_IN_ALL
222 gssize g_socket_receive_message (GSocket *socket,
223 GSocketAddress **address,
224 GInputVector *vectors,
226 GSocketControlMessage ***messages,
229 GCancellable *cancellable,
231 GLIB_AVAILABLE_IN_ALL
232 gssize g_socket_send_message (GSocket *socket,
233 GSocketAddress *address,
234 GOutputVector *vectors,
236 GSocketControlMessage **messages,
239 GCancellable *cancellable,
241 GLIB_AVAILABLE_IN_ALL
242 gboolean g_socket_close (GSocket *socket,
244 GLIB_AVAILABLE_IN_ALL
245 gboolean g_socket_shutdown (GSocket *socket,
246 gboolean shutdown_read,
247 gboolean shutdown_write,
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,
261 GLIB_AVAILABLE_IN_ALL
262 gssize g_socket_receive_with_blocking (GSocket *socket,
266 GCancellable *cancellable,
268 GLIB_AVAILABLE_IN_ALL
269 gssize g_socket_send_with_blocking (GSocket *socket,
273 GCancellable *cancellable,
276 GLIB_AVAILABLE_IN_2_36
277 gboolean g_socket_get_option (GSocket *socket,
282 GLIB_AVAILABLE_IN_2_36
283 gboolean g_socket_set_option (GSocket *socket,
291 #endif /* __G_SOCKET_H__ */