+
+/* For Windows socket calls, 'errno' is not set. One has to call
+ * WSAGetLastError() to get the error number and then pass it to
+ * FormatMessage() (through this function) to get the correct error string.
+
+ * ovs_strerror() calls strerror_r() and would not get the correct error
+ * string for Windows sockets, but is good for POSIX. */
+const char *
+sock_strerror(int error)
+{
+#ifdef _WIN32
+ enum { BUFSIZE = sizeof sockerror_buffer_get()->s };
+ char *buffer = sockerror_buffer_get()->s;
+
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0,
+ buffer, BUFSIZE, NULL);
+ return buffer;
+#else
+ return ovs_strerror(error);
+#endif
+}