Classes Reference

Classes

AppServ | AppServRequest | CustomError | CustomException | Dir | DirEnt | Errno | Event | FD | FS | File | GD | GDFont | GDImage | PG | PGCancel | PGConn | PGDataResult | PGNotifies | PGPrintOpt | PGResult | RecvQ | SendQ | Stat | Syslog


AppServ

(Classes)

Provided by js-appserv(8) only. Allows the JS application to access properties and control functions in order to serve clients as it wishes. See the mmserver2(3) manual page for internal details, on which js-appserv(8) is based. js-appserv(8) consists of a processes pool-based server written in C which delegates control to a JavaScript application to serve the clients.

The application should provide the following functions:
void child_init_hook(void); - To be invoked when a new child process is created in the pool.
void child_exit_hook(void); - To be invoked when the child process exists. Note that a process may serve multiple connections before exiting.
void child_sigalrm_hook(void); - Invoked when a SIGALRM signal is received. Controlled via AppServ.alarm().
void request_handler(req::AppServRequest); - Function to handle the client in normal conditions.
void reject_handler(req::AppServRequest, reason::Number); - Function to handle the client in resource exceeded conditions. Allows to provide a protocol-friendly response before the connection gets closed. reason specifies the reason for the rejection, and may be one of AppServ.REASON_CACHE_SIZE, AppServ.REASON_CONCURRENCY or AppServ.REASON_RATE.
void request_close_hook(req::AppServRequest); - Invoked when the connection to the client is about to be closed, always.
void request_interrupt_hook(req::AppServRequest); - If the server is configured to interrupt currently served clients when the SIGHUP or SIGKILL signals are received, this function is invoked.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(AppServ)

Static Properties

(AppServ)

REASON_CACHE_SIZE | REASON_CONCURRENCY | REASON_RATE

Static Methods

(AppServ)

alarm

Properties

(AppServ)

Methods

(AppServ)


AppServRequest

(Classes)

Client request object. Holds necessary information about the client to communicate with it. Provided as an argument to the request_handler() and reject_handler() user functions.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(AppServRequest)

Static Properties

(AppServRequest)

Static Methods

(AppServRequest)

Properties

(AppServRequest)

client_address_concurrency | client_address_hostname | client_address_name | client_port | client_socket | packet_data | server_socket | server_socket_address_name | server_socket_family | server_socket_port | server_socket_type

Methods

(AppServRequest)


CustomError

(Classes)

Extends Error

This class extends the system Error class as should normally be done. However, when doing so the stack backtrace becomes unavailable, possibly as the result of a SpiderMonkey bug. Thus, it is recommended to use CustomException instead.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(CustomError)

CustomError

Static Properties

(CustomError)

Static Methods

(CustomError)

Properties

(CustomError)

Methods

(CustomError)


CustomException

(Classes)

This actually creates an Error system object and then adds custom properties to this. This allows the stack backtrace to be available which is most useful.

Unlike CustomError, this does not extend the system Error class. This means that the code cannot use instanceof to determine the type of exception/error. Instead, conditionals such as x.name == 'IOException' may be used instead.

The C classes invoke customexception_throw() to generate the same object and also preserve the stack backtrace.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(CustomException)

CustomException

Static Properties

(CustomException)

Static Methods

(CustomException)

Properties

(CustomException)

Methods

(CustomException)


Dir

(Classes)

A C opendir(3) and friends wrapper class. Allows to iterate over directory entries. Also see FD.fstat(). Note that deleting a Dir object also closes the directory.

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(Dir)

Dir

Static Properties

(Dir)

DT_BLK | DT_CHR | DT_DIR | DT_FIFO | DT_LNK | DT_REG | DT_SOCK | DT_UNKNOWN

Static Methods

(Dir)

Properties

(Dir)

Methods

(Dir)

close | read | rewind | seek | tell


DirEnt

(Classes)

Represents a directory entry. Not an actual class per say, but an untyped object, holding properties. These are returned by Dir.read().

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(DirEnt)

Static Properties

(DirEnt)

Static Methods

(DirEnt)

Properties

(DirEnt)

fileno | name | type

Methods

(DirEnt)


Errno

(Classes)

This class allows to work with C and unix native error codes. It simply consists of a wrapper around strerror(3) and errno(2).

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(Errno)

Static Properties

(Errno)

EACCES | EADDRINUSE | EADDRNOTAVAIL | EAFNOSUPPORT | EAGAIN | EALREADY | EBADF | EBADMSG | EBUSY | ECANCELED | ECONNABORTED | ECONNREFUSED | ECONNRESET | EDESTADDRREQ | EDQUOT | EEXIST | EFBIG | EFTYPE | EHOSTDOWN | EHOSTUNREACH | EINPROGRESS | EINTR | EINVAL | EIO | EISCONN | EISDIR | ELOOP | EMFILE | EMLINK | EMSGSIZE | ENAMETOOLONG | ENETDOWN | ENETRESET | ENETUNREACH | ENFILE | ENOBUFS | ENODATA | ENODEV | ENOENT | ENOLCK | ENOMSG | ENOSPC | ENOSYS | ENOTBLK | ENOTCONN | ENOTDIR | ENOTEMPTY | ENOTSOCK | ENOTSUP | ENOTTY | ENXIO | EOPNOTSUPP | EPERM | EPFNOSUPPORT | EPIPE | EPROTONOSUPPORT | EPROTOTYPE | EROFS | ESHUTDOWN | ESPIPE | ESTALE | ETIME | ETIMEDOUT | ETXTBSY | EXDEV

Static Methods

(Errno)

strerror

Properties

(Errno)

Methods

(Errno)


Event

(Classes)

This class allows to use efficient OS primitives for events, through the event(3) library. For instance, on BSD systems, kqueue(2) is used internally, which not only is a system which exceeds dramatically the performance of poll(2), but also supports a number of event types other than for file descriptor polling.

Currently, only file descriptor polling is supported in JS using FD objects. There are however plans to eventually support signal and timer events as well.

This is a callback driven system. This means that you must register descriptors and events you're interested in as well as which JS functions to execute, and call a dispatch function. Very much like unix signal handling. This allows the main processing loop to remain in C.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(Event)

Static Properties

(Event)

EVLOOP_NONBLOCK | EVLOOP_ONCE | EV_PERSIST | EV_READ | EV_SIGNAL | EV_TIMEOUT | EV_WRITE | SIGABRT | SIGALRM | SIGBUS | SIGCHLD | SIGCONT | SIGEMT | SIGFPE | SIGHUP | SIGILL | SIGINFO | SIGINT | SIGIO | SIGKILL | SIGPIPE | SIGPROF | SIGPWR | SIGQUIT | SIGSEGV | SIGSTOP | SIGSYS | SIGTERM | SIGTRAP | SIGTSTP | SIGTTIN | SIGTTOU | SIGURG | SIGUSR1 | SIGUSR2 | SIGVTALRM | SIGWINCH | SIGXCPU | SIGXFSZ

Static Methods

(Event)

addFD | delFD | dispatch | initializedFD | loop | loopExit | onceFD | pendingFD | setFD

Properties

(Event)

Methods

(Event)


FD

(Classes)

Implements support for unix file descriptor objects. Blocking, non-blocking modes are provided, as well as libevent(3) and poll(2) support. IPv4 sockets also are along with socket options. XXX Other address families should eventually be supported, although js-appserv(8) supports them already.

The static properties of this class map to the C equivalent integers. These are required for a number of functions which are basically C function mappings as well, other than having been reorganized to be more OO friendly.

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(FD)

FD

Static Properties

(FD)

AF_INET | F_GETFL | F_SETFL | LOCK_EX | LOCK_NB | LOCK_SH | LOCK_UN | O_CREAT | O_NONBLOCK | O_RDONLY | O_RDWR | O_TRUNC | O_WRONLY | POLLERR | POLLHUP | POLLIN | POLLNVAL | POLLOUT | POLLPRI | POLLRDBAND | POLLRDNORM | POLLWRBAND | POLLWRNORM | SEEK_CUR | SEEK_END | SEEK_SET | SF_APPEND | SF_ARCHIVED | SF_IMMUTABLE | SHUT_RD | SHUT_RDRW | SHUT_RW | SOCK_DGRAM | SOCK_STREAM | SO_BROADCAST | SO_DONTROUTE | SO_ERROR | SO_KEEPALIVE | SO_LINGER | SO_OOBINLINE | SO_RCVBUF | SO_RCVLOWAT | SO_RCVTIMEO | SO_REUSEADDR | SO_REUSEPORT | SO_SNDBUF | SO_SNDLOWAT | SO_SNDTIMEO | SO_TYPE | STDERR_FILENO | STDIN_FILENO | STDOUT_FILENO | S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFMT | S_IFREG | S_IFSOCK | S_IFWHT | S_IRGRP | S_IROTH | S_IRUSR | S_IRWXG | S_IRWXO | S_IRWXU | S_ISGID | S_ISUID | S_ISVTX | S_IWOTH | S_IWUSR | S_IXGRP | S_IXOTH | S_IXUSR | TCP_NODELAY | UF_APPEND | UF_IMMUTABLE | UF_NODUMP | UF_OPAQUE

Static Methods

(FD)

poll

Properties

(FD)

client_addr | client_port | errno | events | fd | mode | path | revents

Methods

(FD)

accept | bind | close | connect | fchmod | fchown | fcntl | fdatasync | flock | fstat | ftruncate | get | getsockopt | listen | lseek | open | put | read | set | setsockopt | shutdown | socket | write


FS

(Classes)

This class wraps around various file system related unix system calls.

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(FS)

Static Properties

(FS)

Static Methods

(FS)

chdir | chmod | chown | creat | getcwd | lchown | mkdir | mkfifo | mknod | rename | rmdir | stat | symlink | truncate | unlink

Properties

(FS)

Methods

(FS)


File

(Classes)

This class consists of a wrapper around C stdio. When it is initialized by the system, three File objects are also created as first-level objects: stdin, stdout and stderr.

Because various C libraries also work with C FILE objects, it was important to implement support for stdio. For instance, the GD and PG classes support it.

See also

Constructors | Static Properties | Static Methods | Properties | Methods

Constructors

(File)

File

Static Properties

(File)

SEEK_CUR | SEEK_END | SEEK_SET | STDERR_FILENO | STDIN_FILENO | STDOUT_FILENO | _IOFBF | _IOLBF | _IONBF

Static Methods

(File)

popen | remove | strerror | tmpfile

Properties

(File)

Methods

(File)

clearerr | close | eof | error | fileno | flush | getc | gets | purge | putc | read | reopen | rewind | seek | setvbuf | tell | ungetc | write