-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[WIP] feat(std): Create net
and net.Socket
Node Polyfill
#8949
Conversation
The I will stop working on this for now until i get back a response |
I'm not sure this could be possible, but I think the This is a part of the example implementation of class Socket extends stream.Duplex {
constructor(options: any) {
super();
}
private connecting: boolean = false;
public pending: boolean = false;
public readyState: boolean = false;
public bufferSize: number = 0;
pause = () => {
// It seems to pause related functions not exists in Deno.Writer
notImplemented();
};
resume = () => {
// It seems to pause related functions not exists in Deno.Writer
notImplemented();
};
public setNoDelay(enable: boolean) {
// It seems to setNoDelay related functions not exists in Deno.Conn
notImplemented();
}
public setKeepAlive(setting: any, msecs: any) {
// It seems to setKeepAlive related functions not exists in Deno.Conn
notImplemented();
}
public address() {
return this.conn!.localAddr;
}
public remoteAddress() {
return this.conn!.remoteAddr;
}
public remoteFamily() {
// It seems to connection family related field not exists in Deno.Conn
}
public remotePort() {}
public destorySoon() {
if (this.writable) this.end();
if (this.writableFinished) this.destroy();
else this.once("finish", this.destroy);
}
public bytesWritten() {}
public conn: Deno.Conn | undefined = undefined;
public connect(
options: TcpSocketConnectOpts | IpcSocketConnectOpts,
connectionListener?: () => void
) {
let connectionPromise: Promise<Deno.Conn>;
if ("port" in options) {
// tcp
options = options as TcpSocketConnectOpts;
connectionPromise = Deno.connect({
port: options.port,
transport: "tcp",
});
} else {
// ipc (not support windows using named pipe)
options = options as IpcSocketConnectOpts;
connectionPromise = Deno.connect({
path: options.path,
transport: "unix",
});
}
let cb = (con: Deno.Conn) => {
this.conn = con;
};
cb = cb.bind(this);
connectionPromise.then(cb);
}
} In the above code, I think And I think maybe in
(https://github.com/nodejs/node/blob/master/lib/net.js#L142) This is the internal binding of And according to what I've seen, some method or field in So, I think we need to migrate these sorts of functions to the rust side first. (Please ignore this comment if my investigation was insufficient and there are some functions performing similar feature in Deno.) |
@jopemachine Definitely a good and useful writeup - so maybe a lot of the functionality just throws a not implemented. This gives me hope, but then i am worried that the Socket API will actually become unusable (thus like i said above, unableto be developed) as even the basic functionality uses internal bindings |
net
and net.Socket
Node Polyfillnet
and net.Socket
Node Polyfill
Deno standard library was moved to denoland/deno_std, please reopen your PR there. |
Partially address #5385
Only adds the
net.Socket
part of the API, but creates the top levelnet
APIChecklist
net.ts
net
has been created, but only supportsnet.Socket
Resources
net.js