[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gethostname, socket need startup code
From: |
Bruno Haible |
Subject: |
Re: gethostname, socket need startup code |
Date: |
Sun, 2 Aug 2009 17:12:13 +0200 |
User-agent: |
KMail/1.9.9 |
Paolo Bonzini wrote:
> I'm wondering if some programs out there used WSAStartup autonomously
> without going through the sockets module...
That would not hurt. WSAStartup succeeds when called repeatedly, even
when called with different version numbers:
$ cat foo.c
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
int main()
{
WSADATA data;
int err;
err = WSAStartup (0x101, &data);
printf ("%d\n", err);
err = WSAStartup (0x101, &data);
printf ("%d\n", err);
err = WSAStartup (0x201, &data);
printf ("%d\n", err);
err = WSAStartup (0x101, &data);
printf ("%d\n", err);
return 0;
}
$ gcc -mno-cygwin foo.c -lws2_32
$ ./a.exe
0
0
0
0
Bruno