GSocket: Add function for setting unicast TTL
[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 guint                  g_socket_get_ttl                 (GSocket                 *socket);
105 void                   g_socket_set_ttl                 (GSocket                 *socket,
106                                                          guint                    ttl);
107
108 gboolean               g_socket_get_multicast_loopback  (GSocket                 *socket);
109 void                   g_socket_set_multicast_loopback  (GSocket                 *socket,
110                                                          gboolean                 loopback);
111 guint                  g_socket_get_multicast_ttl       (GSocket                 *socket);
112 void                   g_socket_set_multicast_ttl       (GSocket                 *socket,
113                                                          guint                    ttl);
114 gboolean               g_socket_is_connected            (GSocket                 *socket);
115 gboolean               g_socket_bind                    (GSocket                 *socket,
116                                                          GSocketAddress          *address,
117                                                          gboolean                 allow_reuse,
118                                                          GError                 **error);
119 gboolean               g_socket_join_multicast_group    (GSocket                 *socket,
120                                                          GInetAddress            *group,
121                                                          gboolean                 source_specific,
122                                                          const gchar             *interface,
123                                                          GError                 **error);
124 gboolean               g_socket_leave_multicast_group   (GSocket                 *socket,
125                                                          GInetAddress            *group,
126                                                          gboolean                 source_specific,
127                                                          const gchar             *interface,
128                                                          GError                 **error);
129 gboolean               g_socket_connect                 (GSocket                 *socket,
130                                                          GSocketAddress          *address,
131                                                          GCancellable            *cancellable,
132                                                          GError                 **error);
133 gboolean               g_socket_check_connect_result    (GSocket                 *socket,
134                                                          GError                 **error);
135
136 GIOCondition           g_socket_condition_check         (GSocket                 *socket,
137                                                          GIOCondition             condition);
138 gboolean               g_socket_condition_wait          (GSocket                 *socket,
139                                                          GIOCondition             condition,
140                                                          GCancellable            *cancellable,
141                                                          GError                 **error);
142 GSocket *              g_socket_accept                  (GSocket                 *socket,
143                                                          GCancellable            *cancellable,
144                                                          GError                 **error);
145 gboolean               g_socket_listen                  (GSocket                 *socket,
146                                                          GError                 **error);
147 gssize                 g_socket_receive                 (GSocket                 *socket,
148                                                          gchar                   *buffer,
149                                                          gsize                    size,
150                                                          GCancellable            *cancellable,
151                                                          GError                 **error);
152 gssize                 g_socket_receive_from            (GSocket                 *socket,
153                                                          GSocketAddress         **address,
154                                                          gchar                   *buffer,
155                                                          gsize                    size,
156                                                          GCancellable            *cancellable,
157                                                          GError                 **error);
158 gssize                 g_socket_send                    (GSocket                 *socket,
159                                                          const gchar             *buffer,
160                                                          gsize                    size,
161                                                          GCancellable            *cancellable,
162                                                          GError                 **error);
163 gssize                 g_socket_send_to                 (GSocket                 *socket,
164                                                          GSocketAddress          *address,
165                                                          const gchar             *buffer,
166                                                          gsize                    size,
167                                                          GCancellable            *cancellable,
168                                                          GError                 **error);
169 gssize                 g_socket_receive_message         (GSocket                 *socket,
170                                                          GSocketAddress         **address,
171                                                          GInputVector            *vectors,
172                                                          gint                     num_vectors,
173                                                          GSocketControlMessage ***messages,
174                                                          gint                    *num_messages,
175                                                          gint                    *flags,
176                                                          GCancellable            *cancellable,
177                                                          GError                 **error);
178 gssize                 g_socket_send_message            (GSocket                 *socket,
179                                                          GSocketAddress          *address,
180                                                          GOutputVector           *vectors,
181                                                          gint                     num_vectors,
182                                                          GSocketControlMessage  **messages,
183                                                          gint                     num_messages,
184                                                          gint                     flags,
185                                                          GCancellable            *cancellable,
186                                                          GError                 **error);
187 gboolean               g_socket_close                   (GSocket                 *socket,
188                                                          GError                 **error);
189 gboolean               g_socket_shutdown                (GSocket                 *socket,
190                                                          gboolean                 shutdown_read,
191                                                          gboolean                 shutdown_write,
192                                                          GError                 **error);
193 gboolean               g_socket_is_closed               (GSocket                 *socket);
194 GSource *              g_socket_create_source           (GSocket                 *socket,
195                                                          GIOCondition             condition,
196                                                          GCancellable            *cancellable);
197 gboolean               g_socket_speaks_ipv4             (GSocket                 *socket);
198 GCredentials          *g_socket_get_credentials         (GSocket                 *socket,
199                                                          GError                 **error);
200
201 gssize                 g_socket_receive_with_blocking   (GSocket                 *socket,
202                                                          gchar                   *buffer,
203                                                          gsize                    size,
204                                                          gboolean                 blocking,
205                                                          GCancellable            *cancellable,
206                                                          GError                 **error);
207 gssize                 g_socket_send_with_blocking      (GSocket                 *socket,
208                                                          const gchar             *buffer,
209                                                          gsize                    size,
210                                                          gboolean                 blocking,
211                                                          GCancellable            *cancellable,
212                                                          GError                 **error);
213
214 G_END_DECLS
215
216 #endif /* __G_SOCKET_H__ */