Browse Source

Whitespace for node_net2.cc

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
263813ae3e
  1. 29
      src/node_net2.cc

29
src/node_net2.cc

@ -29,6 +29,7 @@
#include <errno.h>
namespace node {
using namespace v8;
@ -47,13 +48,15 @@ static Persistent<String> unix_symbol;
static Persistent<FunctionTemplate> recv_msg_template;
#define FD_ARG(a) \
if (!(a)->IsInt32()) { \
return ThrowException(Exception::TypeError( \
String::New("Bad file descriptor argument"))); \
} \
#define FD_ARG(a) \
if (!(a)->IsInt32()) { \
return ThrowException(Exception::TypeError( \
String::New("Bad file descriptor argument"))); \
} \
int fd = (a)->Int32Value();
static inline const char *errno_string(int errorno) {
#define ERRNO_CASE(e) case e: return #e;
switch (errorno) {
@ -394,18 +397,22 @@ static inline Local<Value> ErrnoException(int errorno,
return e;
}
static inline bool SetCloseOnExec(int fd) {
return (fcntl(fd, F_SETFD, FD_CLOEXEC) != -1);
}
static inline bool SetNonBlock(int fd) {
return (fcntl(fd, F_SETFL, O_NONBLOCK) != -1);
}
static inline bool SetSockFlags(int fd) {
return SetNonBlock(fd) && SetCloseOnExec(fd);
}
// Creates nonblocking pipe
static Handle<Value> Pipe(const Arguments& args) {
HandleScope scope;
@ -426,6 +433,7 @@ static Handle<Value> Pipe(const Arguments& args) {
return scope.Close(a);
}
// Creates nonblocking socket pair
static Handle<Value> SocketPair(const Arguments& args) {
HandleScope scope;
@ -450,6 +458,7 @@ static Handle<Value> SocketPair(const Arguments& args) {
return scope.Close(a);
}
// Creates a new non-blocking socket fd
// t.socket("TCP");
// t.socket("UNIX");
@ -597,6 +606,7 @@ static Handle<Value> Close(const Arguments& args) {
return Undefined();
}
// t.shutdown(fd, "read"); -- SHUT_RD
// t.shutdown(fd, "write"); -- SHUT_WR
// t.shutdown(fd, "readwrite"); -- SHUT_RDWR
@ -660,6 +670,7 @@ static Handle<Value> Connect(const Arguments& args) {
return Undefined();
}
static Handle<Value> GetSockName(const Arguments& args) {
HandleScope scope;
@ -691,6 +702,7 @@ static Handle<Value> GetSockName(const Arguments& args) {
return scope.Close(info);
}
static Handle<Value> GetPeerName(const Arguments& args) {
HandleScope scope;
@ -804,6 +816,7 @@ static Handle<Value> SocketError(const Arguments& args) {
return scope.Close(Integer::New(error));
}
// var bytesRead = t.read(fd, buffer, offset, length);
// returns null on EAGAIN or EINTR, raises an exception on all other errors
// returns 0 on EOF.
@ -846,6 +859,7 @@ static Handle<Value> Read(const Arguments& args) {
return scope.Close(Integer::New(bytes_read));
}
// bytesRead = t.recvMsg(fd, buffer, offset, length)
// if (recvMsg.fd) {
// receivedFd = recvMsg.fd;
@ -962,6 +976,7 @@ static Handle<Value> Write(const Arguments& args) {
return scope.Close(Integer::New(written));
}
// var bytesWritten = t.sendFD(self.fd)
// returns null on EAGAIN or EINTR, raises an exception on all other errors
static Handle<Value> SendFD(const Arguments& args) {
@ -1017,6 +1032,7 @@ static Handle<Value> SendFD(const Arguments& args) {
return scope.Close(Integer::New(written));
}
// Probably only works for Linux TCP sockets?
// Returns the amount of data on the read queue.
static Handle<Value> ToRead(const Arguments& args) {
@ -1052,7 +1068,10 @@ static Handle<Value> SetNoDelay(const Arguments& args) {
}
//
// G E T A D D R I N F O
//
struct resolve_request {
Persistent<Function> cb;

Loading…
Cancel
Save