#include <glib-object.h>
#include <gio/gio.h>
-#include "ginetaddress.h"
+#include <gnio/gsocketaddress.h>
G_BEGIN_DECLS
#define G_IS_SOCKET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SOCKET))
#define G_SOCKET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SOCKET, GSocket))
-typedef struct _GSocket GSocket;
-typedef struct _GSocketClass GSocketClass;
+typedef struct _GSocket GSocket;
+typedef struct _GSocketClass GSocketClass;
+typedef struct _GSocketPrivate GSocketPrivate;
struct _GSocket
{
GObject parent;
+
+ GSocketPrivate *priv;
};
struct _GSocketClass
GObjectClass parent_class;
};
-GType g_socket_get_type (void) G_GNUC_CONST;
+typedef enum
+{
+ G_SOCKET_DOMAIN_INET,
+ G_SOCKET_DOMAIN_INET6,
+ G_SOCKET_DOMAIN_UNIX
+} GSocketDomain;
+
+typedef enum
+{
+ G_SOCKET_TYPE_STREAM,
+ G_SOCKET_TYPE_DATAGRAM,
+ G_SOCKET_TYPE_SEQPACKET
+} GSocketType;
+
+GType g_socket_get_type (void) G_GNUC_CONST;
+
+GSocket * g_socket_new (GSocketDomain domain,
+ GSocketType type,
+ const gchar *protocol,
+ GError **error);
+
+GSocket * g_socket_new_from_fd (gint fd);
+
+GSocketAddress * g_socket_get_local_address (GSocket *socket, GError **error);
+
+GSocketAddress * g_socket_get_remote_address (GSocket *socket, GError **error);
+
+void g_socket_set_blocking (GSocket *socket,
+ gboolean blocking);
+
+gboolean g_socket_get_blocking (GSocket *socket);
+
+void g_socket_set_reuse_address (GSocket *socket,
+ gboolean reuse);
+
+gboolean g_socket_get_reuse_address (GSocket *socket);
+
+gboolean g_socket_bind (GSocket *socket,
+ GSocketAddress *address,
+ GError **error);
+
+gboolean g_socket_connect (GSocket *socket,
+ GSocketAddress *address,
+ GError **error);
-GSocket * g_socket_new ();
+GSocket * g_socket_accept (GSocket *socket,
+ GError **error);
-void g_socket_bind (GSocket *socket, GInetAddress *address);
+gboolean g_socket_listen (GSocket *socket,
+ GError **error);
-GSocket * g_socket_accept (GSocket *socket);
+gssize g_socket_receive (GSocket *socket,
+ gchar *buffer,
+ gsize size,
+ GError **error);
-void g_socket_accept_async (GSocket *socket);
+gssize g_socket_send (GSocket *socket,
+ const gchar *buffer,
+ gsize size,
+ GError **error);
-GSocket * g_socket_accept_finish (GSocket *socket);
+void g_socket_close (GSocket *socket);
-void g_socket_listen (GSocket *socket, int backlog);
+GSource * g_socket_create_source (GSocket *socket,
+ GIOCondition condition,
+ GCancellable *cancellable);
G_END_DECLS