Subject: Re: mingw32 sock-faq examples?
From: [email-masked] (Michael Weiser)

21 Jun 1998 14:52:19 -0700
Message-ID: <358ebfa3.1081134.cygnus.gnu-win32@mail>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

Hi Laszlo,

You wrote:

>Has anyone gotten the Unix Sockets FAQ examples to compile with mingw32?
>
>	http://www.ibrado.com/sock-faq/
>
>I'm using the stock egcs-mingw32 distribution from cygnus, linking the
>examples against -lwsock32 (including windows.h and windows32/sockets.h),
>but listen(), accept(), connect() etc are always failing with -1.
>gethostname() also doesnt work, though IP addresses seem ok.
On Win32 it is neccessary to initialize socket functions using
WSAStartup() and clean them up at end using WSACleanup().

	WSADATA wsadata;

	/* 0x0101 can be replaced with MAKEWORD(1, 1) and
	** is the wanted version number of WINSOCK.DLL */
        if (WSAStartup(0x0101, &wsadata) == SOCKET_ERROR)
          {
            printf("error initializing Windows Sockets 1.1");
            return 0;
          }

	<socket code>

	WSACleanup();

Hope that helps.

bye

Michael
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".