String::New("Bad file descriptor argument"))); \
}
+
+#ifdef __POSIX__
+
static inline bool SetCloseOnExec(int fd) {
return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1);
}
+#endif // __POSIX__
+
static inline bool SetNonBlock(int fd) {
#ifdef __MINGW32__
}
+#ifdef __POSIX__
+
// Creates nonblocking pipe
static Handle<Value> Pipe(const Arguments& args) {
HandleScope scope;
return scope.Close(a);
}
-
// Creates nonblocking socket pair
static Handle<Value> SocketPair(const Arguments& args) {
HandleScope scope;
return Undefined();
}
+#endif // __POSIX__
+
static Handle<Value> Close(const Arguments& args) {
HandleScope scope;
}
+#ifdef __POSIX__
+
// t.shutdown(fd, "read"); -- SHUT_RD
// t.shutdown(fd, "write"); -- SHUT_WR
// t.shutdown(fd, "readwrite"); -- SHUT_RDWR
return scope.Close(Integer::New(error));
}
+#endif // __POSIX__
+
// var bytesRead = t.read(fd, buffer, offset, length);
// returns null on EAGAIN or EINTR, raises an exception on all other errors
return scope.Close(Integer::New(bytes_read));
}
+#ifdef __POSIX__
+
// var info = t.recvfrom(fd, buffer, offset, length, flags);
// info.size // bytes read
// info.port // from port
return scope.Close(Integer::New(bytes_read));
}
+#endif // __POSIX__
+
// var bytesWritten = t.write(fd, buffer, offset, length);
// returns null on EAGAIN or EINTR, raises an exception on all other errors
}
+#ifdef __POSIX__
+
// var bytes = sendmsg(fd, buf, off, len, fd, flags);
//
// Write a buffer with optional offset and length to the given file
return scope.Close(exception);
}
+#endif // __POSIX__
+
void InitNet(Handle<Object> target) {
HandleScope scope;
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "read", Read);
+#ifdef __POSIX__
NODE_SET_METHOD(target, "sendMsg", SendMsg);
NODE_SET_METHOD(target, "recvfrom", RecvFrom);
NODE_SET_METHOD(target, "sendto", SendTo);
target->Set(String::NewSymbol("recvMsg"), recv_msg_template->GetFunction());
NODE_SET_METHOD(target, "socket", Socket);
+#endif //__POSIX__
+
NODE_SET_METHOD(target, "close", Close);
+
+#ifdef __POSIX__
NODE_SET_METHOD(target, "shutdown", Shutdown);
NODE_SET_METHOD(target, "pipe", Pipe);
NODE_SET_METHOD(target, "socketpair", SocketPair);
NODE_SET_METHOD(target, "getaddrinfo", GetAddrInfo);
NODE_SET_METHOD(target, "isIP", IsIP);
NODE_SET_METHOD(target, "errnoException", CreateErrnoException);
+#endif // __POSIX__
errno_symbol = NODE_PSYMBOL("errno");
syscall_symbol = NODE_PSYMBOL("syscall");