gsocketconnection.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* GIO - GLib Input, Output and Streaming Library
  2. * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  3. * Copyright © 2009 Codethink Limited
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General
  18. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Authors: Christian Kellner <gicmo@gnome.org>
  21. * Samuel Cormier-Iijima <sciyoshi@gmail.com>
  22. * Ryan Lortie <desrt@desrt.ca>
  23. * Alexander Larsson <alexl@redhat.com>
  24. */
  25. #ifndef __G_SOCKET_CONNECTION_H__
  26. #define __G_SOCKET_CONNECTION_H__
  27. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  28. #error "Only <gio/gio.h> can be included directly."
  29. #endif
  30. #include <glib-object.h>
  31. #include <gio/gsocket.h>
  32. #include <gio/giostream.h>
  33. G_BEGIN_DECLS
  34. #define G_TYPE_SOCKET_CONNECTION (g_socket_connection_get_type ())
  35. #define G_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  36. G_TYPE_SOCKET_CONNECTION, GSocketConnection))
  37. #define G_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  38. G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass))
  39. #define G_IS_SOCKET_CONNECTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  40. G_TYPE_SOCKET_CONNECTION))
  41. #define G_IS_SOCKET_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  42. G_TYPE_SOCKET_CONNECTION))
  43. #define G_SOCKET_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  44. G_TYPE_SOCKET_CONNECTION, GSocketConnectionClass))
  45. typedef struct _GSocketConnectionPrivate GSocketConnectionPrivate;
  46. typedef struct _GSocketConnectionClass GSocketConnectionClass;
  47. struct _GSocketConnectionClass
  48. {
  49. GIOStreamClass parent_class;
  50. /* Padding for future expansion */
  51. void (*_g_reserved1) (void);
  52. void (*_g_reserved2) (void);
  53. void (*_g_reserved3) (void);
  54. void (*_g_reserved4) (void);
  55. void (*_g_reserved5) (void);
  56. void (*_g_reserved6) (void);
  57. };
  58. struct _GSocketConnection
  59. {
  60. GIOStream parent_instance;
  61. GSocketConnectionPrivate *priv;
  62. };
  63. GIO_AVAILABLE_IN_ALL
  64. GType g_socket_connection_get_type (void) G_GNUC_CONST;
  65. GIO_AVAILABLE_IN_2_32
  66. gboolean g_socket_connection_is_connected (GSocketConnection *connection);
  67. GIO_AVAILABLE_IN_2_32
  68. gboolean g_socket_connection_connect (GSocketConnection *connection,
  69. GSocketAddress *address,
  70. GCancellable *cancellable,
  71. GError **error);
  72. GIO_AVAILABLE_IN_2_32
  73. void g_socket_connection_connect_async (GSocketConnection *connection,
  74. GSocketAddress *address,
  75. GCancellable *cancellable,
  76. GAsyncReadyCallback callback,
  77. gpointer user_data);
  78. GIO_AVAILABLE_IN_2_32
  79. gboolean g_socket_connection_connect_finish (GSocketConnection *connection,
  80. GAsyncResult *result,
  81. GError **error);
  82. GIO_AVAILABLE_IN_ALL
  83. GSocket *g_socket_connection_get_socket (GSocketConnection *connection);
  84. GIO_AVAILABLE_IN_ALL
  85. GSocketAddress *g_socket_connection_get_local_address (GSocketConnection *connection,
  86. GError **error);
  87. GIO_AVAILABLE_IN_ALL
  88. GSocketAddress *g_socket_connection_get_remote_address (GSocketConnection *connection,
  89. GError **error);
  90. GIO_AVAILABLE_IN_ALL
  91. void g_socket_connection_factory_register_type (GType g_type,
  92. GSocketFamily family,
  93. GSocketType type,
  94. gint protocol);
  95. GIO_AVAILABLE_IN_ALL
  96. GType g_socket_connection_factory_lookup_type (GSocketFamily family,
  97. GSocketType type,
  98. gint protocol_id);
  99. GIO_AVAILABLE_IN_ALL
  100. GSocketConnection *g_socket_connection_factory_create_connection (GSocket *socket);
  101. G_END_DECLS
  102. #endif /* __G_SOCKET_CONNECTION_H__ */