#ifndef SOCKET_UTIL_H
#define SOCKET_UTIL_H 1
+#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
}
#endif
+/* In Windows platform, errno is not set for socket calls.
+ * The last error has to be gotten from WSAGetLastError(). */
+static inline int sock_errno(void)
+{
+#ifdef _WIN32
+ return WSAGetLastError();
+#else
+ return errno;
+#endif
+}
+
#endif /* socket-util.h */