Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

195 linhas
9.5 KiB

  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. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  25. #error "Only <gio/gio.h> can be included directly."
  26. #endif
  27. #ifndef __G_SOCKET_H__
  28. #define __G_SOCKET_H__
  29. #include <gio/giotypes.h>
  30. G_BEGIN_DECLS
  31. #define G_TYPE_SOCKET (g_socket_get_type ())
  32. #define G_SOCKET(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  33. G_TYPE_SOCKET, GSocket))
  34. #define G_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  35. G_TYPE_SOCKET, GSocketClass))
  36. #define G_IS_SOCKET(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  37. G_TYPE_SOCKET))
  38. #define G_IS_SOCKET_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  39. G_TYPE_SOCKET))
  40. #define G_SOCKET_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  41. G_TYPE_SOCKET, GSocketClass))
  42. typedef struct _GSocketPrivate GSocketPrivate;
  43. typedef struct _GSocketClass GSocketClass;
  44. struct _GSocketClass
  45. {
  46. GObjectClass parent_class;
  47. /*< private >*/
  48. /* Padding for future expansion */
  49. void (*_g_reserved1) (void);
  50. void (*_g_reserved2) (void);
  51. void (*_g_reserved3) (void);
  52. void (*_g_reserved4) (void);
  53. void (*_g_reserved5) (void);
  54. void (*_g_reserved6) (void);
  55. void (*_g_reserved7) (void);
  56. void (*_g_reserved8) (void);
  57. void (*_g_reserved9) (void);
  58. void (*_g_reserved10) (void);
  59. };
  60. struct _GSocket
  61. {
  62. GObject parent_instance;
  63. GSocketPrivate *priv;
  64. };
  65. GType g_socket_get_type (void) G_GNUC_CONST;
  66. GSocket * g_socket_new (GSocketFamily family,
  67. GSocketType type,
  68. GSocketProtocol protocol,
  69. GError **error);
  70. GSocket * g_socket_new_from_fd (gint fd,
  71. GError **error);
  72. int g_socket_get_fd (GSocket *socket);
  73. GSocketFamily g_socket_get_family (GSocket *socket);
  74. GSocketType g_socket_get_socket_type (GSocket *socket);
  75. GSocketProtocol g_socket_get_protocol (GSocket *socket);
  76. GSocketAddress * g_socket_get_local_address (GSocket *socket,
  77. GError **error);
  78. GSocketAddress * g_socket_get_remote_address (GSocket *socket,
  79. GError **error);
  80. void g_socket_set_blocking (GSocket *socket,
  81. gboolean blocking);
  82. gboolean g_socket_get_blocking (GSocket *socket);
  83. void g_socket_set_keepalive (GSocket *socket,
  84. gboolean keepalive);
  85. gboolean g_socket_get_keepalive (GSocket *socket);
  86. gint g_socket_get_listen_backlog (GSocket *socket);
  87. void g_socket_set_listen_backlog (GSocket *socket,
  88. gint backlog);
  89. guint g_socket_get_timeout (GSocket *socket);
  90. void g_socket_set_timeout (GSocket *socket,
  91. guint timeout);
  92. gboolean g_socket_is_connected (GSocket *socket);
  93. gboolean g_socket_bind (GSocket *socket,
  94. GSocketAddress *address,
  95. gboolean allow_reuse,
  96. GError **error);
  97. gboolean g_socket_connect (GSocket *socket,
  98. GSocketAddress *address,
  99. GCancellable *cancellable,
  100. GError **error);
  101. gboolean g_socket_check_connect_result (GSocket *socket,
  102. GError **error);
  103. GIOCondition g_socket_condition_check (GSocket *socket,
  104. GIOCondition condition);
  105. gboolean g_socket_condition_wait (GSocket *socket,
  106. GIOCondition condition,
  107. GCancellable *cancellable,
  108. GError **error);
  109. GSocket * g_socket_accept (GSocket *socket,
  110. GCancellable *cancellable,
  111. GError **error);
  112. gboolean g_socket_listen (GSocket *socket,
  113. GError **error);
  114. gssize g_socket_receive (GSocket *socket,
  115. gchar *buffer,
  116. gsize size,
  117. GCancellable *cancellable,
  118. GError **error);
  119. gssize g_socket_receive_from (GSocket *socket,
  120. GSocketAddress **address,
  121. gchar *buffer,
  122. gsize size,
  123. GCancellable *cancellable,
  124. GError **error);
  125. gssize g_socket_send (GSocket *socket,
  126. const gchar *buffer,
  127. gsize size,
  128. GCancellable *cancellable,
  129. GError **error);
  130. gssize g_socket_send_to (GSocket *socket,
  131. GSocketAddress *address,
  132. const gchar *buffer,
  133. gsize size,
  134. GCancellable *cancellable,
  135. GError **error);
  136. gssize g_socket_receive_message (GSocket *socket,
  137. GSocketAddress **address,
  138. GInputVector *vectors,
  139. gint num_vectors,
  140. GSocketControlMessage ***messages,
  141. gint *num_messages,
  142. gint *flags,
  143. GCancellable *cancellable,
  144. GError **error);
  145. gssize g_socket_send_message (GSocket *socket,
  146. GSocketAddress *address,
  147. GOutputVector *vectors,
  148. gint num_vectors,
  149. GSocketControlMessage **messages,
  150. gint num_messages,
  151. gint flags,
  152. GCancellable *cancellable,
  153. GError **error);
  154. gboolean g_socket_close (GSocket *socket,
  155. GError **error);
  156. gboolean g_socket_shutdown (GSocket *socket,
  157. gboolean shutdown_read,
  158. gboolean shutdown_write,
  159. GError **error);
  160. gboolean g_socket_is_closed (GSocket *socket);
  161. GSource * g_socket_create_source (GSocket *socket,
  162. GIOCondition condition,
  163. GCancellable *cancellable);
  164. gboolean g_socket_speaks_ipv4 (GSocket *socket);
  165. GCredentials *g_socket_get_credentials (GSocket *socket,
  166. GError **error);
  167. gssize g_socket_receive_with_blocking (GSocket *socket,
  168. gchar *buffer,
  169. gsize size,
  170. gboolean blocking,
  171. GCancellable *cancellable,
  172. GError **error);
  173. gssize g_socket_send_with_blocking (GSocket *socket,
  174. const gchar *buffer,
  175. gsize size,
  176. gboolean blocking,
  177. GCancellable *cancellable,
  178. GError **error);
  179. G_END_DECLS
  180. #endif /* __G_SOCKET_H__ */