Remove g_socket_set/get_reuse_address from header
[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                                                          gint                     protocol_id,
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 gint                   g_socket_get_protocol_id         (GSocket                 *socket);
87 char *                 g_socket_get_protocol_name       (GSocket                 *socket);
88 GSocketAddress *       g_socket_get_local_address       (GSocket                 *socket,
89                                                          GError                 **error);
90 GSocketAddress *       g_socket_get_remote_address      (GSocket                 *socket,
91                                                          GError                 **error);
92 void                   g_socket_set_blocking            (GSocket                 *socket,
93                                                          gboolean                 blocking);
94 gboolean               g_socket_get_blocking            (GSocket                 *socket);
95 void                   g_socket_set_keepalive           (GSocket                 *socket,
96                                                          gboolean                 keepalive);
97 gboolean               g_socket_get_keepalive           (GSocket                 *socket);
98 gint                   g_socket_get_listen_backlog      (GSocket                 *socket);
99 void                   g_socket_set_listen_backlog      (GSocket                 *socket,
100                                                          gint                     backlog);
101 gboolean               g_socket_is_connected            (GSocket                 *socket);
102 gboolean               g_socket_bind                    (GSocket                 *socket,
103                                                          GSocketAddress          *address,
104                                                          gboolean                 allow_reuse,
105                                                          GError                 **error);
106 gboolean               g_socket_connect                 (GSocket                 *socket,
107                                                          GSocketAddress          *address,
108                                                          GError                 **error);
109 gboolean               g_socket_check_pending_error     (GSocket                 *socket,
110                                                          GError                 **error);
111 GIOCondition           g_socket_condition_check         (GSocket                 *socket,
112                                                          GIOCondition             condition);
113 gboolean               g_socket_condition_wait          (GSocket                 *socket,
114                                                          GIOCondition             condition,
115                                                          GCancellable            *cancellable,
116                                                          GError                 **error);
117 GSocket *              g_socket_accept                  (GSocket                 *socket,
118                                                          GError                 **error);
119 gboolean               g_socket_listen                  (GSocket                 *socket,
120                                                          GError                 **error);
121 gssize                 g_socket_receive                 (GSocket                 *socket,
122                                                          gchar                   *buffer,
123                                                          gsize                    size,
124                                                          GError                 **error);
125 gssize                 g_socket_receive_from            (GSocket                 *socket,
126                                                          GSocketAddress         **address,
127                                                          gchar                   *buffer,
128                                                          gsize                    size,
129                                                          GError                 **error);
130 gssize                 g_socket_send                    (GSocket                 *socket,
131                                                          const gchar             *buffer,
132                                                          gsize                    size,
133                                                          GError                 **error);
134 gssize                 g_socket_send_to                 (GSocket                 *socket,
135                                                          GSocketAddress          *address,
136                                                          const gchar             *buffer,
137                                                          gsize                    size,
138                                                          GError                 **error);
139 GSocketControlMessage *g_socket_receive_control_message (GSocket                 *socket,
140                                                          GError                 **error);
141 gboolean               g_socket_send_control_message    (GSocket                 *socket,
142                                                          GSocketControlMessage   *message,
143                                                          GError                 **error);
144 gssize                 g_socket_receive_message         (GSocket                 *socket,
145                                                          GSocketAddress         **address,
146                                                          GInputVector            *vectors,
147                                                          gint                     num_vectors,
148                                                          GSocketControlMessage ***messages,
149                                                          gint                    *num_messages,
150                                                          gint                    *flags,
151                                                          GError                 **error);
152 gssize                 g_socket_send_message            (GSocket                 *socket,
153                                                          GSocketAddress          *address,
154                                                          GOutputVector           *vectors,
155                                                          gint                     num_vectors,
156                                                          GSocketControlMessage  **messages,
157                                                          gint                     num_messages,
158                                                          gint                     flags,
159                                                          GError                 **error);
160 gboolean               g_socket_close                   (GSocket                 *socket,
161                                                          GError                 **error);
162 gboolean               g_socket_is_closed               (GSocket                 *socket);
163 GSource *              g_socket_create_source           (GSocket                 *socket,
164                                                          GIOCondition             condition,
165                                                          GCancellable            *cancellable);
166
167 gint                  g_socket_protocol_id_lookup_by_name (const char            *protocol_name);
168
169 G_END_DECLS
170
171 #endif /* __G_SOCKET_H__ */