gsocketaddress.h \
ginetsocketaddress.h \
gsocket.h \
+ gnetworkinputstream.h \
+ gnetworkoutputstream.h \
$(NULL)
gioincludedir=$(includedir)/glib-2.0/gnio/
gsocketaddress.c \
ginetsocketaddress.c \
gsocket.c \
+ gnetworkinputstream.c \
+ gnetworkoutputstream.c \
$(NULL)
G_DEFINE_TYPE (GInet4Address, g_inet4_address, G_TYPE_INET_ADDRESS);
-struct _GInet4AddressPrivate {
+struct _GInet4AddressPrivate
+{
union {
guint8 u4_addr8[4];
guint32 u4_addr32;
G_DEFINE_TYPE (GInet6Address, g_inet6_address, G_TYPE_INET_ADDRESS);
-struct _GInet6AddressPrivate {
+struct _GInet6AddressPrivate
+{
union {
guint8 u6_addr8[16];
guint16 u6_addr16[8];
PROP_PORT
};
-struct _GInetSocketAddressPrivate {
+struct _GInetSocketAddressPrivate
+{
GInetAddress *address;
guint16 port;
};
--- /dev/null
+/* GNIO - GLib Network Layer of GIO
+ *
+ * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Christian Kellner <gicmo@gnome.org>
+ * Samuel Cormier-Iijima <sciyoshi@gmail.com>
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <string.h>
+#ifndef G_OS_WIN32
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#else
+# include <winsock2.h>
+# include <winerror.h>
+# include <ws2tcpip.h>
+# undef HAVE_GETADDRINFO
+# define HAVE_GETHOSTBYNAME_THREADSAFE 1
+#endif
+#include <errno.h>
+
+#include "ginetaddress.h"
+#include "ginet4address.h"
+#include "ginet6address.h"
+#include "gnetworkinputstream.h"
+#include "gnioerror.h"
+
+G_DEFINE_TYPE (GNetworkInputStream, g_network_input_stream, G_TYPE_INPUT_STREAM);
+
+static void
+g_network_input_stream_class_init (GNetworkInputStreamClass *klass)
+{
+ GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass);
+}
+
+static void
+g_network_input_stream_init (GNetworkInputStream *address)
+{
+
+}
--- /dev/null
+/* GNIO - GLib Network Layer of GIO
+ *
+ * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Christian Kellner <gicmo@gnome.org>
+ * Samuel Cormier-Iijima <sciyoshi@gmail.com>
+ */
+
+#ifndef G_NETWORK_INPUT_STREAM_H
+#define G_NETWORK_INPUT_STREAM_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "gsocket.h"
+
+G_BEGIN_DECLS
+
+#define G_TYPE_NETWORK_INPUT_STREAM (g_socket_get_type ())
+#define G_NETWORK_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_INPUT_STREAM, GNetworkInputStream))
+#define G_NETWORK_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NETWORK_INPUT_STREAM, GNetworkInputStreamClass))
+#define G_IS_NETWORK_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_INPUT_STREAM))
+#define G_IS_NETWORK_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NETWORK_INPUT_STREAM))
+#define G_NETWORK_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_NETWORK_INPUT_STREAM, GNetworkInputStream))
+
+typedef struct _GNetworkInputStream GNetworkInputStream;
+typedef struct _GNetworkInputStreamClass GNetworkInputStreamClass;
+
+struct _GNetworkInputStream
+{
+ GInputStream parent;
+};
+
+struct _GNetworkInputStreamClass
+{
+ GInputStreamClass parent_class;
+};
+
+GType g_network_input_stream_get_type (void) G_GNUC_CONST;
+
+GNetworkInputStream * g_network_input_stream_new (GSocket *socket);
+
+G_END_DECLS
+
+#endif /* G_NETWORK_INPUT_STREAM_H */
+
--- /dev/null
+/* GNIO - GLib Network Layer of GIO
+ *
+ * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Christian Kellner <gicmo@gnome.org>
+ * Samuel Cormier-Iijima <sciyoshi@gmail.com>
+ */
+
+#include <config.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <string.h>
+#ifndef G_OS_WIN32
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#else
+# include <winsock2.h>
+# include <winerror.h>
+# include <ws2tcpip.h>
+# undef HAVE_GETADDRINFO
+# define HAVE_GETHOSTBYNAME_THREADSAFE 1
+#endif
+#include <errno.h>
+
+#include "ginetaddress.h"
+#include "ginet4address.h"
+#include "ginet6address.h"
+#include "gnetworkoutputstream.h"
+#include "gnioerror.h"
+
+G_DEFINE_TYPE (GNetworkOutputStream, g_network_output_stream, G_TYPE_OUTPUT_STREAM);
+
+static void
+g_network_output_stream_class_init (GNetworkOutputStreamClass *klass)
+{
+ GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass);
+}
+
+static void
+g_network_output_stream_init (GNetworkOutputStream *address)
+{
+
+}
--- /dev/null
+/* GNIO - GLib Network Layer of GIO
+ *
+ * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Christian Kellner <gicmo@gnome.org>
+ * Samuel Cormier-Iijima <sciyoshi@gmail.com>
+ */
+
+#ifndef G_NETWORK_OUTPUT_STREAM_H
+#define G_NETWORK_OUTPUT_STREAM_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "gsocket.h"
+
+G_BEGIN_DECLS
+
+#define G_TYPE_NETWORK_OUTPUT_STREAM (g_socket_get_type ())
+#define G_NETWORK_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_OUTPUT_STREAM, GNetworkOutputStream))
+#define G_NETWORK_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_NETWORK_OUTPUT_STREAM, GNetworkOutputStreamClass))
+#define G_IS_NETWORK_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_OUTPUT_STREAM))
+#define G_IS_NETWORK_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_NETWORK_OUTPUT_STREAM))
+#define G_NETWORK_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_NETWORK_OUTPUT_STREAM, GNetworkOutputStream))
+
+typedef struct _GNetworkOutputStream GNetworkOutputStream;
+typedef struct _GNetworkOutputStreamClass GNetworkOutputStreamClass;
+
+struct _GNetworkOutputStream
+{
+ GOutputStream parent;
+};
+
+struct _GNetworkOutputStreamClass
+{
+ GOutputStreamClass parent_class;
+};
+
+GType g_network_output_stream_get_type (void) G_GNUC_CONST;
+
+GNetworkOutputStream * g_network_output_stream_new (GSocket *socket);
+
+G_END_DECLS
+
+#endif /* G_NETWORK_OUTPUT_STREAM_H */
+
GObjectClass parent_class;
};
-GType g_resolver_get_type (void) G_GNUC_CONST;
+GType g_resolver_get_type (void) G_GNUC_CONST;
GInetAddress * g_resolver_resolve (GResolver *resolver,
const char *host,
#include "ginet6address.h"
#include "gsocket.h"
#include "gnioerror.h"
-#include "gsocket.h"
+#include "ginetsocketaddress.h"
G_DEFINE_TYPE (GSocket, g_socket, G_TYPE_OBJECT);
+struct _GSocketPrivate
+{
+ int fd;
+};
+
static void
g_socket_class_init (GSocketClass *klass)
{
GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GSocketPrivate));
}
static void
g_socket_init (GSocket *address)
{
+ address->priv = G_TYPE_INSTANCE_GET_PRIVATE (address, G_TYPE_SOCKET, GSocketPrivate);
+}
+
+GSocket *
+g_socket_new ()
+{
+ return G_SOCKET (g_object_new (G_TYPE_SOCKET, NULL));
+}
+
+void
+g_socket_listen (GSocket *socket, gint backlog)
+{
+ g_return_if_fail (G_IS_SOCKET (socket));
+ listen (socket->priv->fd, backlog);
}
#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;
+GType g_socket_get_type (void) G_GNUC_CONST;
-GSocket * g_socket_new ();
+GSocket * g_socket_new (void);
-void g_socket_bind (GSocket *socket,
- GSocketAddress *address);
+gboolean g_socket_bind (GSocket *socket,
+ GSocketAddress *address,
+ GError **error);
void g_socket_connect (GSocket *socket,
GSocketAddress *address,