aboutsummaryrefslogtreecommitdiff
path: root/qemu-sockets.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2010-04-01 19:57:08 +0200
committerAurelien Jarno <aurelien@aurel32.net>2010-04-09 18:55:54 +0200
commit0706a4dcce88942462ca85aa2dcea0795ee655c4 (patch)
tree4ee14b47e16e41aa1d576bbaf077d99933f74418 /qemu-sockets.c
parente9d0fc74636cd713414c17139659ad2f69a46da0 (diff)
move socket_init to qemu-sockets.c
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'qemu-sockets.c')
-rw-r--r--qemu-sockets.c24
1 files changed, 24 insertions, 0 deletions
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;
+}