gsocketlistener.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
  4. * Copyright © 2009 Codethink Limited
  5. * Copyright © 2009 Red Hat, Inc
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published
  9. * by the Free Software Foundation; either version 2 of the licence or (at
  10. * 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 <[email protected]>
  21. * Samuel Cormier-Iijima <[email protected]>
  22. * Ryan Lortie <[email protected]>
  23. * Alexander Larsson <[email protected]>
  24. */
  25. #ifndef __G_SOCKET_LISTENER_H__
  26. #define __G_SOCKET_LISTENER_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 <gio/giotypes.h>
  31. G_BEGIN_DECLS
  32. #define G_TYPE_SOCKET_LISTENER (g_socket_listener_get_type ())
  33. #define G_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  34. G_TYPE_SOCKET_LISTENER, GSocketListener))
  35. #define G_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  36. G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
  37. #define G_IS_SOCKET_LISTENER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  38. G_TYPE_SOCKET_LISTENER))
  39. #define G_IS_SOCKET_LISTENER_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  40. G_TYPE_SOCKET_LISTENER))
  41. #define G_SOCKET_LISTENER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  42. G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
  43. typedef struct _GSocketListenerPrivate GSocketListenerPrivate;
  44. typedef struct _GSocketListenerClass GSocketListenerClass;
  45. /**
  46. * GSocketListenerClass:
  47. * @changed: virtual method called when the set of socket listened to changes
  48. **/
  49. struct _GSocketListenerClass
  50. {
  51. GObjectClass parent_class;
  52. void (* changed) (GSocketListener *listener);
  53. /* Padding for future expansion */
  54. void (*_g_reserved1) (void);
  55. void (*_g_reserved2) (void);
  56. void (*_g_reserved3) (void);
  57. void (*_g_reserved4) (void);
  58. void (*_g_reserved5) (void);
  59. void (*_g_reserved6) (void);
  60. };
  61. struct _GSocketListener
  62. {
  63. GObject parent_instance;
  64. GSocketListenerPrivate *priv;
  65. };
  66. GLIB_AVAILABLE_IN_ALL
  67. GType g_socket_listener_get_type (void) G_GNUC_CONST;
  68. GLIB_AVAILABLE_IN_ALL
  69. GSocketListener * g_socket_listener_new (void);
  70. GLIB_AVAILABLE_IN_ALL
  71. void g_socket_listener_set_backlog (GSocketListener *listener,
  72. int listen_backlog);
  73. GLIB_AVAILABLE_IN_ALL
  74. gboolean g_socket_listener_add_socket (GSocketListener *listener,
  75. GSocket *socket,
  76. GObject *source_object,
  77. GError **error);
  78. GLIB_AVAILABLE_IN_ALL
  79. gboolean g_socket_listener_add_address (GSocketListener *listener,
  80. GSocketAddress *address,
  81. GSocketType type,
  82. GSocketProtocol protocol,
  83. GObject *source_object,
  84. GSocketAddress **effective_address,
  85. GError **error);
  86. GLIB_AVAILABLE_IN_ALL
  87. gboolean g_socket_listener_add_inet_port (GSocketListener *listener,
  88. guint16 port,
  89. GObject *source_object,
  90. GError **error);
  91. GLIB_AVAILABLE_IN_ALL
  92. guint16 g_socket_listener_add_any_inet_port (GSocketListener *listener,
  93. GObject *source_object,
  94. GError **error);
  95. GLIB_AVAILABLE_IN_ALL
  96. GSocket * g_socket_listener_accept_socket (GSocketListener *listener,
  97. GObject **source_object,
  98. GCancellable *cancellable,
  99. GError **error);
  100. GLIB_AVAILABLE_IN_ALL
  101. void g_socket_listener_accept_socket_async (GSocketListener *listener,
  102. GCancellable *cancellable,
  103. GAsyncReadyCallback callback,
  104. gpointer user_data);
  105. GLIB_AVAILABLE_IN_ALL
  106. GSocket * g_socket_listener_accept_socket_finish (GSocketListener *listener,
  107. GAsyncResult *result,
  108. GObject **source_object,
  109. GError **error);
  110. GLIB_AVAILABLE_IN_ALL
  111. GSocketConnection * g_socket_listener_accept (GSocketListener *listener,
  112. GObject **source_object,
  113. GCancellable *cancellable,
  114. GError **error);
  115. GLIB_AVAILABLE_IN_ALL
  116. void g_socket_listener_accept_async (GSocketListener *listener,
  117. GCancellable *cancellable,
  118. GAsyncReadyCallback callback,
  119. gpointer user_data);
  120. GLIB_AVAILABLE_IN_ALL
  121. GSocketConnection * g_socket_listener_accept_finish (GSocketListener *listener,
  122. GAsyncResult *result,
  123. GObject **source_object,
  124. GError **error);
  125. GLIB_AVAILABLE_IN_ALL
  126. void g_socket_listener_close (GSocketListener *listener);
  127. G_END_DECLS
  128. #endif /* __G_SOCKET_LISTENER_H__ */