docs: Add GIOModuleScope and GIOModuleScopeFlags
[glib.git] / gio / gsocket.h
blob1ad6a6fc4e57aa427c626ad71641bddcff8be816
1 /*
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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26 #error "Only <gio/gio.h> can be included directly."
27 #endif
29 #ifndef __G_SOCKET_H__
30 #define __G_SOCKET_H__
32 #include <gio/giotypes.h>
34 G_BEGIN_DECLS
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))
48 typedef struct _GSocketPrivate GSocketPrivate;
49 typedef struct _GSocketClass GSocketClass;
51 struct _GSocketClass
53 GObjectClass parent_class;
55 /*< private >*/
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);
70 struct _GSocket
72 GObject parent_instance;
73 GSocketPrivate *priv;
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);
104 guint g_socket_get_ttl (GSocket *socket);
105 void g_socket_set_ttl (GSocket *socket,
106 guint ttl);
108 gboolean g_socket_get_broadcast (GSocket *socket);
109 void g_socket_set_broadcast (GSocket *socket,
110 gboolean broadcast);
112 gboolean g_socket_get_multicast_loopback (GSocket *socket);
113 void g_socket_set_multicast_loopback (GSocket *socket,
114 gboolean loopback);
115 guint g_socket_get_multicast_ttl (GSocket *socket);
116 void g_socket_set_multicast_ttl (GSocket *socket,
117 guint ttl);
118 gboolean g_socket_is_connected (GSocket *socket);
119 gboolean g_socket_bind (GSocket *socket,
120 GSocketAddress *address,
121 gboolean allow_reuse,
122 GError **error);
123 gboolean g_socket_join_multicast_group (GSocket *socket,
124 GInetAddress *group,
125 gboolean source_specific,
126 const gchar *iface,
127 GError **error);
128 gboolean g_socket_leave_multicast_group (GSocket *socket,
129 GInetAddress *group,
130 gboolean source_specific,
131 const gchar *iface,
132 GError **error);
133 gboolean g_socket_connect (GSocket *socket,
134 GSocketAddress *address,
135 GCancellable *cancellable,
136 GError **error);
137 gboolean g_socket_check_connect_result (GSocket *socket,
138 GError **error);
140 gssize g_socket_get_available_bytes (GSocket *socket);
142 GIOCondition g_socket_condition_check (GSocket *socket,
143 GIOCondition condition);
144 gboolean g_socket_condition_wait (GSocket *socket,
145 GIOCondition condition,
146 GCancellable *cancellable,
147 GError **error);
148 GSocket * g_socket_accept (GSocket *socket,
149 GCancellable *cancellable,
150 GError **error);
151 gboolean g_socket_listen (GSocket *socket,
152 GError **error);
153 gssize g_socket_receive (GSocket *socket,
154 gchar *buffer,
155 gsize size,
156 GCancellable *cancellable,
157 GError **error);
158 gssize g_socket_receive_from (GSocket *socket,
159 GSocketAddress **address,
160 gchar *buffer,
161 gsize size,
162 GCancellable *cancellable,
163 GError **error);
164 gssize g_socket_send (GSocket *socket,
165 const gchar *buffer,
166 gsize size,
167 GCancellable *cancellable,
168 GError **error);
169 gssize g_socket_send_to (GSocket *socket,
170 GSocketAddress *address,
171 const gchar *buffer,
172 gsize size,
173 GCancellable *cancellable,
174 GError **error);
175 gssize g_socket_receive_message (GSocket *socket,
176 GSocketAddress **address,
177 GInputVector *vectors,
178 gint num_vectors,
179 GSocketControlMessage ***messages,
180 gint *num_messages,
181 gint *flags,
182 GCancellable *cancellable,
183 GError **error);
184 gssize g_socket_send_message (GSocket *socket,
185 GSocketAddress *address,
186 GOutputVector *vectors,
187 gint num_vectors,
188 GSocketControlMessage **messages,
189 gint num_messages,
190 gint flags,
191 GCancellable *cancellable,
192 GError **error);
193 gboolean g_socket_close (GSocket *socket,
194 GError **error);
195 gboolean g_socket_shutdown (GSocket *socket,
196 gboolean shutdown_read,
197 gboolean shutdown_write,
198 GError **error);
199 gboolean g_socket_is_closed (GSocket *socket);
200 GSource * g_socket_create_source (GSocket *socket,
201 GIOCondition condition,
202 GCancellable *cancellable);
203 gboolean g_socket_speaks_ipv4 (GSocket *socket);
204 GCredentials *g_socket_get_credentials (GSocket *socket,
205 GError **error);
207 gssize g_socket_receive_with_blocking (GSocket *socket,
208 gchar *buffer,
209 gsize size,
210 gboolean blocking,
211 GCancellable *cancellable,
212 GError **error);
213 gssize g_socket_send_with_blocking (GSocket *socket,
214 const gchar *buffer,
215 gsize size,
216 gboolean blocking,
217 GCancellable *cancellable,
218 GError **error);
220 G_END_DECLS
222 #endif /* __G_SOCKET_H__ */