0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

Port GetHostName

This commit is contained in:
Bert Belder 2010-12-21 00:07:02 +01:00
parent 2d8ab90613
commit 86518c3b11

View File

@ -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"));
}