gsocketconnection.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* GIO - GLib Input, Output and Streaming Library
  2. * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  3. * Copyright © 2009 Codethink Limited
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published
  7. * by the Free Software Foundation; either version 2 of the licence or (at
  8. * 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, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Authors: Christian Kellner <[email protected]>
  19. * Samuel Cormier-Iijima <[email protected]>
  20. * Ryan Lortie <[email protected]>
  21. * Alexander Larsson <[email protected]>
  22. */
  23. #ifndef __G_SOCKET_CONNECTION_H__
  24. #define __G_SOCKET_CONNECTION_H__
  25. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  26. #error "Only <gio/gio.h> can be included directly."
  27. #endif
  28. #include <glib-object.h>
  29. #include <gio/gsocket.h>
  30. #include <gio/giostream.h>
  31. G_BEGIN_DECLS
  32. #define G_TYPE_SOCKET_CONNECTION (g_socket_connection_get_type ())
  33. #define G_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  34. G_TYPE_SOCKET_CONNECTION, GSocketConnection))
  35. #define G_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  36. G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass))
  37. #define G_IS_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  38. G_TYPE_SOCKET_CONNECTION))
  39. #define G_IS_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  40. G_TYPE_SOCKET_CONNECTION))
  41. #define G_SOCKET_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  42. G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass))
  43. typedef struct _GSocketConnectionPrivate GSocketConnectionPrivate;
  44. typedef struct _GSocketConnectionClass GSocketConnectionClass;
  45. struct _GSocketConnectionClass
  46. {
  47. GIOStreamClass parent_class;
  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. };
  56. struct _GSocketConnection
  57. {
  58. GIOStream parent_instance;
  59. GSocketConnectionPrivate *priv;
  60. };
  61. GLIB_AVAILABLE_IN_ALL
  62. GType g_socket_connection_get_type (void) G_GNUC_CONST;
  63. GLIB_AVAILABLE_IN_2_32
  64. gboolean g_socket_connection_is_connected (GSocketConnection *connection);
  65. GLIB_AVAILABLE_IN_2_32
  66. gboolean g_socket_connection_connect (GSocketConnection *connection,
  67. GSocketAddress *address,
  68. GCancellable *cancellable,
  69. GError **error);
  70. GLIB_AVAILABLE_IN_2_32
  71. void g_socket_connection_connect_async (GSocketConnection *connection,
  72. GSocketAddress *address,
  73. GCancellable *cancellable,
  74. GAsyncReadyCallback callback,
  75. gpointer user_data);
  76. GLIB_AVAILABLE_IN_2_32
  77. gboolean g_socket_connection_connect_finish (GSocketConnection *connection,
  78. GAsyncResult *result,
  79. GError **error);
  80. GLIB_AVAILABLE_IN_ALL
  81. GSocket *g_socket_connection_get_socket (GSocketConnection *connection);
  82. GLIB_AVAILABLE_IN_ALL
  83. GSocketAddress *g_socket_connection_get_local_address (GSocketConnection *connection,
  84. GError **error);
  85. GLIB_AVAILABLE_IN_ALL
  86. GSocketAddress *g_socket_connection_get_remote_address (GSocketConnection *connection,
  87. GError **error);
  88. GLIB_AVAILABLE_IN_ALL
  89. void g_socket_connection_factory_register_type (GType g_type,
  90. GSocketFamily family,
  91. GSocketType type,
  92. gint protocol);
  93. GLIB_AVAILABLE_IN_ALL
  94. GType g_socket_connection_factory_lookup_type (GSocketFamily family,
  95. GSocketType type,
  96. gint protocol_id);
  97. GLIB_AVAILABLE_IN_ALL
  98. GSocketConnection *g_socket_connection_factory_create_connection (GSocket *socket);
  99. G_END_DECLS
  100. #endif /* __G_SOCKET_CONNECTION_H__ */