From 0706a4dcce88942462ca85aa2dcea0795ee655c4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 1 Apr 2010 19:57:08 +0200 Subject: move socket_init to qemu-sockets.c Signed-off-by: Paolo Bonzini Signed-off-by: Aurelien Jarno --- qemu-sockets.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'qemu-sockets.c') diff --git a/qemu-sockets.c b/qemu-sockets.c index 23c3def2a4..a7399aa945 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -648,3 +648,27 @@ int unix_connect(const char *path) } #endif + +#ifdef _WIN32 +static void socket_cleanup(void) +{ + WSACleanup(); +} +#endif + +int socket_init(void) +{ +#ifdef _WIN32 + WSADATA Data; + int ret, err; + + ret = WSAStartup(MAKEWORD(2,2), &Data); + if (ret != 0) { + err = WSAGetLastError(); + fprintf(stderr, "WSAStartup: %d\n", err); + return -1; + } + atexit(socket_cleanup); +#endif + return 0; +} -- cgit v1.2.1