From 5e4f10ab70978804fed4afcb1a45ac5b6b2206cd Mon Sep 17 00:00:00 2001 From: Samuel CORMIER-IIJIMA Date: Fri, 25 Jan 2008 17:45:48 -0500 Subject: [PATCH] First set of changes for windows --- AUTHORS | 1 + INSTALL | 702 ++++++++++++++++++++++++++++++++++++++ Makefile.am | 1 - configure.ac | 1 - gnio/Makefile.am | 2 + gnio/ginet4address.c | 23 +- gnio/ginet4address.h | 23 ++ gnio/ginet6address.c | 5 +- gnio/ginet6address.h | 23 ++ gnio/ginetaddress.c | 7 +- gnio/ginetaddress.h | 23 ++ gnio/ginetsocketaddress.c | 7 +- gnio/ginetsocketaddress.h | 23 ++ gnio/gnio.h | 9 +- gnio/gnioerror.h | 9 +- gnio/gresolver.c | 153 ++++++++- gnio/gresolver.h | 23 ++ gnio/gsocket.c | 61 ++++ gnio/gsocket.h | 59 ++++ gnio/gsocketaddress.c | 7 +- gnio/gsocketaddress.h | 23 ++ test/Makefile.am | 2 +- test/test-stuff.c | 10 +- 23 files changed, 1163 insertions(+), 34 deletions(-) create mode 100644 gnio/gsocket.c create mode 100644 gnio/gsocket.h diff --git a/AUTHORS b/AUTHORS index 04488ed..e01455e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,2 @@ Christian Kellner +Samuel Cormier-Iijima diff --git a/INSTALL b/INSTALL index e69de29..3477f80 100644 --- a/INSTALL +++ b/INSTALL @@ -0,0 +1,702 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am index 1493bf7..008f097 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,6 @@ NULL = SUBDIRS = \ gnio \ - po \ test \ $(NULL) diff --git a/configure.ac b/configure.ac index 6c76996..d2a587d 100644 --- a/configure.ac +++ b/configure.ac @@ -326,7 +326,6 @@ AC_OUTPUT([ Makefile gnio/Makefile test/Makefile -po/Makefile.in ]) echo diff --git a/gnio/Makefile.am b/gnio/Makefile.am index 2bf1f93..dfb4d13 100644 --- a/gnio/Makefile.am +++ b/gnio/Makefile.am @@ -17,6 +17,7 @@ gnio_headers = \ gresolver.h \ gsocketaddress.h \ ginetsocketaddress.h \ + gsocket.h \ $(NULL) gioincludedir=$(includedir)/glib-2.0/gnio/ @@ -31,6 +32,7 @@ libgnio_la_SOURCES = \ gresolver.c \ gsocketaddress.c \ ginetsocketaddress.c \ + gsocket.c \ $(NULL) diff --git a/gnio/ginet4address.c b/gnio/ginet4address.c index a7473f8..7ab6361 100644 --- a/gnio/ginet4address.c +++ b/gnio/ginet4address.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO * - * Copyright (C) 2008 Christian Kellner + * 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 @@ -17,14 +17,20 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include #include -#include -#include +#ifndef G_OS_WIN32 +# include +# include +#else +# include +# define IN_LOOPBACKNET 127 +#endif #include "ginet4address.h" @@ -178,11 +184,20 @@ g_inet4_address_from_string (const gchar *string) { struct in_addr addr; +#ifndef G_OS_WIN32 if (!inet_aton (string, &addr)) { g_warning ("Could not parse IP address %s", string); return NULL; } +#else + addr.s_addr = inet_addr (string); + if (addr.s_addr == INADDR_NONE) + { + g_warning ("Could not parse IP address %s", string); + return NULL; + } +#endif return g_inet4_address_from_bytes ((guint8 *) &(addr.s_addr)); } diff --git a/gnio/ginet4address.h b/gnio/ginet4address.h index e9e8f59..cee9812 100644 --- a/gnio/ginet4address.h +++ b/gnio/ginet4address.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_INET4_ADDRESS_H #define G_INET4_ADDRESS_H diff --git a/gnio/ginet6address.c b/gnio/ginet6address.c index 3fff994..e46ff76 100644 --- a/gnio/ginet6address.c +++ b/gnio/ginet6address.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO * - * Copyright (C) 2008 Christian Kellner + * 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include diff --git a/gnio/ginet6address.h b/gnio/ginet6address.h index ea85526..951e604 100644 --- a/gnio/ginet6address.h +++ b/gnio/ginet6address.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_INET6_ADDRESS_H #define G_INET6_ADDRESS_H diff --git a/gnio/ginetaddress.c b/gnio/ginetaddress.c index ed02fc3..4ee20de 100644 --- a/gnio/ginetaddress.c +++ b/gnio/ginetaddress.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO - * - * Copyright (C) 2008 Christian Kellner + * + * 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include diff --git a/gnio/ginetaddress.h b/gnio/ginetaddress.h index eec559e..cdc8048 100644 --- a/gnio/ginetaddress.h +++ b/gnio/ginetaddress.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_INET_ADDRESS_H #define G_INET_ADDRESS_H diff --git a/gnio/ginetsocketaddress.c b/gnio/ginetsocketaddress.c index 5682657..1771240 100644 --- a/gnio/ginetsocketaddress.c +++ b/gnio/ginetsocketaddress.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO - * - * Copyright (C) 2008 Christian Kellner + * + * 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include diff --git a/gnio/ginetsocketaddress.h b/gnio/ginetsocketaddress.h index f4cfef5..670a5e7 100644 --- a/gnio/ginetsocketaddress.h +++ b/gnio/ginetsocketaddress.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_INET_SOCKET_ADDRESS_H #define G_INET_SOCKET_ADDRESS_H diff --git a/gnio/gnio.h b/gnio/gnio.h index de14013..64e64fa 100644 --- a/gnio/gnio.h +++ b/gnio/gnio.h @@ -1,6 +1,6 @@ -/* GIO - GLib Input, Output and Streaming Library - * - * Copyright (C) 2006-2007 Red Hat, Inc. +/* 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Alexander Larsson + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #ifndef __GNIO_H__ diff --git a/gnio/gnioerror.h b/gnio/gnioerror.h index d188fdb..77fb069 100644 --- a/gnio/gnioerror.h +++ b/gnio/gnioerror.h @@ -1,6 +1,6 @@ -/* GIO - GLib Input, Output and Streaming Library - * - * Copyright (C) 2006-2007 Red Hat, Inc. +/* 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Alexander Larsson + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #ifndef __GNIO_ERROR_H__ diff --git a/gnio/gresolver.c b/gnio/gresolver.c index af46ae9..c5ff2e7 100644 --- a/gnio/gresolver.c +++ b/gnio/gresolver.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO - * - * Copyright (C) 2008 Christian Kellner + * + * 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include @@ -25,9 +26,17 @@ #include #include -#include -#include -#include +#ifndef G_OS_WIN32 +# include +# include +# include +#else +# include +# include +# include +# undef HAVE_GETADDRINFO +# define HAVE_GETHOSTBYNAME_THREADSAFE 1 +#endif #include #include "ginetaddress.h" @@ -45,6 +54,126 @@ G_DEFINE_TYPE (GResolver, g_resolver, G_TYPE_OBJECT); G_LOCK_DEFINE (dnslock); #endif +#ifdef G_OS_WIN32 +/* This is copied straight from giowin32.c, but its static there... */ +/* Is there another way to get this functionality? */ +static char * +winsock_error_message (int number) +{ + static char unk[100]; + + switch (number) { + case WSAEINTR: + return "Interrupted function call"; + case WSAEACCES: + return "Permission denied"; + case WSAEFAULT: + return "Bad address"; + case WSAEINVAL: + return "Invalid argument"; + case WSAEMFILE: + return "Too many open sockets"; + case WSAEWOULDBLOCK: + return "Resource temporarily unavailable"; + case WSAEINPROGRESS: + return "Operation now in progress"; + case WSAEALREADY: + return "Operation already in progress"; + case WSAENOTSOCK: + return "Socket operation on nonsocket"; + case WSAEDESTADDRREQ: + return "Destination address required"; + case WSAEMSGSIZE: + return "Message too long"; + case WSAEPROTOTYPE: + return "Protocol wrong type for socket"; + case WSAENOPROTOOPT: + return "Bad protocol option"; + case WSAEPROTONOSUPPORT: + return "Protocol not supported"; + case WSAESOCKTNOSUPPORT: + return "Socket type not supported"; + case WSAEOPNOTSUPP: + return "Operation not supported on transport endpoint"; + case WSAEPFNOSUPPORT: + return "Protocol family not supported"; + case WSAEAFNOSUPPORT: + return "Address family not supported by protocol family"; + case WSAEADDRINUSE: + return "Address already in use"; + case WSAEADDRNOTAVAIL: + return "Address not available"; + case WSAENETDOWN: + return "Network interface is not configured"; + case WSAENETUNREACH: + return "Network is unreachable"; + case WSAENETRESET: + return "Network dropped connection on reset"; + case WSAECONNABORTED: + return "Software caused connection abort"; + case WSAECONNRESET: + return "Connection reset by peer"; + case WSAENOBUFS: + return "No buffer space available"; + case WSAEISCONN: + return "Socket is already connected"; + case WSAENOTCONN: + return "Socket is not connected"; + case WSAESHUTDOWN: + return "Can't send after socket shutdown"; + case WSAETIMEDOUT: + return "Connection timed out"; + case WSAECONNREFUSED: + return "Connection refused"; + case WSAEHOSTDOWN: + return "Host is down"; + case WSAEHOSTUNREACH: + return "Host is unreachable"; + case WSAEPROCLIM: + return "Too many processes"; + case WSASYSNOTREADY: + return "Network subsystem is unavailable"; + case WSAVERNOTSUPPORTED: + return "Winsock.dll version out of range"; + case WSANOTINITIALISED: + return "Successful WSAStartup not yet performed"; + case WSAEDISCON: + return "Graceful shutdown in progress"; + case WSATYPE_NOT_FOUND: + return "Class type not found"; + case WSAHOST_NOT_FOUND: + return "Host not found"; + case WSATRY_AGAIN: + return "Nonauthoritative host not found"; + case WSANO_RECOVERY: + return "This is a nonrecoverable error"; + case WSANO_DATA: + return "Valid name, no data record of requested type"; + case WSA_INVALID_HANDLE: + return "Specified event object handle is invalid"; + case WSA_INVALID_PARAMETER: + return "One or more parameters are invalid"; + case WSA_IO_INCOMPLETE: + return "Overlapped I/O event object not in signaled state"; + case WSA_NOT_ENOUGH_MEMORY: + return "Insufficient memory available"; + case WSA_OPERATION_ABORTED: + return "Overlapped operation aborted"; + case WSAEINVALIDPROCTABLE: + return "Invalid procedure table from service provider"; + case WSAEINVALIDPROVIDER: + return "Invalid service provider version number"; + case WSAEPROVIDERFAILEDINIT: + return "Unable to initialize a service provider"; + case WSASYSCALLFAILURE: + return "System call failure"; + default: + sprintf (unk, "Unknown WinSock error %d", number); + return unk; + } +} +#endif + #if !defined(HAVE_GETADDRINFO) static GList * hostent2list (const struct hostent *he) @@ -94,8 +223,12 @@ g_io_error_from_addrinfo (GError** error, int err) if (message == NULL) { +#ifndef G_OS_WIN32 /* FIXME: is gai_strerror() thread-safe? */ message = gai_strerror (err); +#else + message = winsock_error_message (WSAGetLastError ()); +#endif } *error = g_error_new_literal (G_IO_ERROR, code, message); @@ -143,7 +276,10 @@ g_resolver_get_host_by_name (GResolver *resolver, const gchar *hostname, GError struct hostent *he = gethostbyname (hostname); if (!he) - g_io_error_from_errno (error); + { + if (error) + *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, winsock_error_message (WSAGetLastError ())); + } else list = hostent2list (he); } @@ -216,6 +352,9 @@ g_resolver_get_host_by_name (GResolver *resolver, const gchar *hostname, GError if (list) list = g_list_reverse (list); + if (!list && error) + *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, winsock_error_message (WSAGetLastError ())); + return list; } diff --git a/gnio/gresolver.h b/gnio/gresolver.h index 33e935e..cfc5892 100644 --- a/gnio/gresolver.h +++ b/gnio/gresolver.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_RESOLVER_H #define G_RESOLVER_H diff --git a/gnio/gsocket.c b/gnio/gsocket.c new file mode 100644 index 0000000..c6d1ce9 --- /dev/null +++ b/gnio/gsocket.c @@ -0,0 +1,61 @@ +/* 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 + * Samuel Cormier-Iijima + */ + +#include +#include +#include + +#include +#ifndef G_OS_WIN32 +# include +# include +# include +#else +# include +# include +# include +# undef HAVE_GETADDRINFO +# define HAVE_GETHOSTBYNAME_THREADSAFE 1 +#endif +#include + +#include "ginetaddress.h" +#include "ginet4address.h" +#include "ginet6address.h" +#include "gsocket.h" +#include "gnioerror.h" +#include "gsocket.h" + +G_DEFINE_TYPE (GSocket, g_socket, G_TYPE_OBJECT); + +static void +g_socket_class_init (GSocketClass *klass) +{ + GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass); +} + +static void +g_socket_init (GSocket *address) +{ + +} diff --git a/gnio/gsocket.h b/gnio/gsocket.h new file mode 100644 index 0000000..6b663d4 --- /dev/null +++ b/gnio/gsocket.h @@ -0,0 +1,59 @@ +/* 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 + * Samuel Cormier-Iijima + */ + +#ifndef G_SOCKET_H +#define G_SOCKET_H + +#include +#include + +#include "ginetaddress.h" + +G_BEGIN_DECLS + +#define G_TYPE_SOCKET (g_socket_get_type ()) +#define G_SOCKET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SOCKET, GSocket)) +#define G_SOCKET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SOCKET, GSocketClass)) +#define G_IS_SOCKET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SOCKET)) +#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; + +struct _GSocket +{ + GObject parent; +}; + +struct _GSocketClass +{ + GObjectClass parent_class; +}; + +GType g_socket_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* G_SOCKET_H */ + diff --git a/gnio/gsocketaddress.c b/gnio/gsocketaddress.c index 5dc4fd5..88b4700 100644 --- a/gnio/gsocketaddress.c +++ b/gnio/gsocketaddress.c @@ -1,6 +1,6 @@ /* GNIO - GLib Network Layer of GIO - * - * Copyright (C) 2008 Christian Kellner + * + * 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 @@ -17,7 +17,8 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Christian Kellner + * Authors: Christian Kellner + * Samuel Cormier-Iijima */ #include diff --git a/gnio/gsocketaddress.h b/gnio/gsocketaddress.h index 09a5a9b..72fdcce 100644 --- a/gnio/gsocketaddress.h +++ b/gnio/gsocketaddress.h @@ -1,3 +1,26 @@ +/* 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 + * Samuel Cormier-Iijima + */ + #ifndef G_SOCKET_ADDRESS_H #define G_SOCKET_ADDRESS_H diff --git a/test/Makefile.am b/test/Makefile.am index 7ddbaf0..81bd00f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,7 +7,7 @@ AM_CFLAGS = \ -DG_DISABLE_DEPRECATED AM_LDFLAGS = \ - $(GLIB_LIBS) ../gnio/libgnio.la -lgnio + -lgnio $(GLIB_LIBS) ../gnio/libgnio.la noinst_PROGRAMS = \ test-stuff \ diff --git a/test/test-stuff.c b/test/test-stuff.c index 0972fad..9ccfc3c 100644 --- a/test/test-stuff.c +++ b/test/test-stuff.c @@ -5,6 +5,8 @@ #include #include +#include + GMainLoop *loop; void print_address (GInetAddress *address, gpointer data); @@ -51,11 +53,17 @@ int main (int argc, char *argv[]) GInetAddress *address; GResolver *resolver; GError *error = NULL; + WSADATA wsaData; - loop = g_main_loop_new (NULL, FALSE); + g_thread_init (NULL); g_type_init (); + if (WSAStartup (MAKEWORD (2, 2), &wsaData) != 0) + return 0; + + loop = g_main_loop_new (NULL, FALSE); + address = (GInetAddress *) g_inet4_address_from_string ("127.0.0.1"); g_printf ("%s:\n", g_inet4_address_to_string (G_INET4_ADDRESS (address))); -- 2.20.1