-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design Core Interface that wraps libuv #2
Comments
You can see the general libuv shape in the luv docs and libuv's docs |
new uv.Tcp(flags) -> uv_tcp_tCreate a new If Below when tcp.open(fd)Open an existing file descriptor or SOCKET as a TCP handle. The file descriptor is set to non-blocking mode. tcp.nodelay(enable)Enable / disable Nagle’s algorithm. tcp.keepalive(enable, delay)Enable / disable simultaneous asynchronous accept requests that are queued by the operating system when listening for new TCP connections. This setting is used to tune a TCP server for the desired performance. Having simultaneous accepts can significantly improve the rate of accepting connections (which is why it is enabled by default) but may lead to uneven load distribution in multi-process setups. ... |
Start of docs is at https://github.com/creationix/nucleus/blob/master/api/uv.md |
This task is to design the interface that wraps libuv and exposes it to JavaScript. This should be as minimal as possible while still feeling like natural JavaScript and not C.
For example, in libuv, there is a hierarchy of structs that act like classes with inheritance. In JS, we can use prototype chains for the
uv_tcp_t
methods that inherits fromuv_stream_t
methods that inherits fromuv_handle_t
methods.All libuv functions are plain C functions. There are no classes. The ones that act like methods accept the struct as the first argument. In luv, I exposed these in both ways.
For example, here is a sample TCP echo server in plain luv.
In lua, there are no methods per-se, but the
obj:name(...)
syntax means to callobj.name(obj, ...)
injecting the thing to the left of the colon as the first argument. In JS, we havethis
which can be used in a similar way.The text was updated successfully, but these errors were encountered: