Permalink
Browse files

Port GetHostName

  • Loading branch information...
1 parent 2d8ab90 commit 86518c3b1101a20fafb8d213d0d68988cb4407fe @piscisaureus piscisaureus committed Dec 20, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/node_os.cc
View
@@ -4,7 +4,12 @@
#include <v8.h>
#include <errno.h>
-#include <unistd.h> // gethostname
+
+#ifdef __POSIX__
+# include <unistd.h> // gethostname
+#else // __MINGW32__
+# include <winsock2.h> // gethostname
+#endif // __MINGW32__
namespace node {
@@ -16,6 +21,9 @@ static Handle<Value> GetHostname(const Arguments& args) {
int r = gethostname(s, 255);
if (r < 0) {
+#ifdef __MINGW32__
+ errno = WSAGetLastError() - WSABASEERR;
+#endif
return ThrowException(ErrnoException(errno, "gethostname"));
}

0 comments on commit 86518c3

Please sign in to comment.