-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add impl for node sockets (wip) (#214)
* feat: add initial impl for node sockets * chore: update sockets tests * feat: add TcpSocketImpl * chore: temp disable eslint in lib/sockets/** * chore: refactor instanceNetwork + dropNetwork * chore: tcp socket impl wip * chore: createTcpSocket/startBind/finishBind * fix: dupe-class-members * chore: add throws entry to jsdoc * chore: improve startBind() logic * chore: improve startConnect() + test * chore: improve tcp-socket impl * refactor: start-* finish-* methods to match specs * chore: use assertion statement in tcp-socket-impl * refactor: tcp-socket-impl * chore: use err.code to catch sockets errors * chore: migrate tcp-socket-impl to use tcp_wrap * chore: mock listen and connect calls * fix: bind connectReq.oncomplete to class method * chore: reorder test suites * chore: add e2e test for tcp-socket-impl * chore: hook up internal events * chore: update impl to match latest wit specs * fix: support bind6 and connect6 * chore: move assert to own file * chore: use assert * chore: use ipv6 in tests * chore: add streams to tcp-socket-impl (wip) * fix: add error code -49 address-not-bindable * feat: add udp-socket-impl method signatures * fix: handle error -99 * chore: document udp errors * chore: wip * feat(udp): wip impl * chore: clean imports * chore: use new folder structure * chore(udp): use Symbols for local state * chore: sync impl with lastest specs * chore: remove useless logs * chore(udp): fix according to conformance tests * fix(tcp): removed deprecated methods * chore: try to reuse an existing udp socket (wip) * fix: make conformance preview2_udp_states pass * feat: add ip-name-lookup (wip) * chore: socket resolve addresses (#1) * chore: add missing import from node:dns/promises * chore: resolve ipv6 :: and ::1 * fix(udp): make preview2_udp_sockopts apss * chore: delete unused code * chore: add comments * chore: more conformance tests passing! * chore: use enums for socket conn state * chore: make preview2_tcp_states pass * fix: make preview2_tcp_connect pass (wip) * fix: refactor isUnicastIpAddress * fix: make preview2_tcp_bind pass * fix: make preview2_tcp_connect pass * chore: refactor code * chore: preview2_tcp_sample_application wip * fix: preview2_tcp_bind and preview2_udp_bind * chore: stashing wip fixes * fix: improve tests and add more comments for hop limits * chore: rename errorState property * fix: make unit tests pass * chore: fix linting --------- Co-authored-by: Guy Bedford <[email protected]>
- Loading branch information
1 parent
3810b69
commit 64475eb
Showing
14 changed files
with
2,473 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function assert(condition, tag, _val) { | ||
if (condition) { | ||
// TODO: throw meaningful errors | ||
// NOTE: wasmtime conformance tests are expecting a string here (a tag) | ||
throw tag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ export { | |
sockets, | ||
cli | ||
} | ||
|
||
export { WasiSockets } from "./sockets/wasi-sockets.js"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,200 +1,11 @@ | ||
export const instanceNetwork = { | ||
instanceNetwork () { | ||
console.log(`[sockets] instance network`); | ||
} | ||
}; | ||
|
||
export const ipNameLookup = { | ||
dropResolveAddressStream () { | ||
|
||
}, | ||
subscribe () { | ||
|
||
}, | ||
resolveAddresses () { | ||
|
||
}, | ||
resolveNextAddress () { | ||
|
||
}, | ||
nonBlocking () { | ||
|
||
}, | ||
setNonBlocking () { | ||
|
||
}, | ||
}; | ||
|
||
export const network = { | ||
dropNetwork () { | ||
|
||
} | ||
}; | ||
|
||
export const tcpCreateSocket = { | ||
createTcpSocket () { | ||
|
||
} | ||
}; | ||
|
||
export const tcp = { | ||
subscribe () { | ||
|
||
}, | ||
dropTcpSocket() { | ||
|
||
}, | ||
bind() { | ||
|
||
}, | ||
connect() { | ||
|
||
}, | ||
listen() { | ||
|
||
}, | ||
accept() { | ||
|
||
}, | ||
localAddress() { | ||
|
||
}, | ||
remoteAddress() { | ||
|
||
}, | ||
addressFamily() { | ||
|
||
}, | ||
ipv6Only() { | ||
|
||
}, | ||
setIpv6Only() { | ||
|
||
}, | ||
setListenBacklogSize() { | ||
|
||
}, | ||
keepAlive() { | ||
|
||
}, | ||
setKeepAlive() { | ||
|
||
}, | ||
noDelay() { | ||
|
||
}, | ||
setNoDelay() { | ||
|
||
}, | ||
unicastHopLimit() { | ||
|
||
}, | ||
setUnicastHopLimit() { | ||
|
||
}, | ||
receiveBufferSize() { | ||
|
||
}, | ||
setReceiveBufferSize() { | ||
|
||
}, | ||
sendBufferSize() { | ||
|
||
}, | ||
setSendBufferSize() { | ||
|
||
}, | ||
nonBlocking() { | ||
|
||
}, | ||
setNonBlocking() { | ||
|
||
}, | ||
shutdown() { | ||
|
||
} | ||
}; | ||
|
||
export const udp = { | ||
subscribe () { | ||
|
||
}, | ||
|
||
dropUdpSocket () { | ||
|
||
}, | ||
|
||
bind () { | ||
|
||
}, | ||
|
||
connect () { | ||
|
||
}, | ||
|
||
receive () { | ||
|
||
}, | ||
|
||
send () { | ||
|
||
}, | ||
|
||
localAddress () { | ||
|
||
}, | ||
|
||
remoteAddress () { | ||
|
||
}, | ||
|
||
addressFamily () { | ||
|
||
}, | ||
|
||
ipv6Only () { | ||
|
||
}, | ||
|
||
setIpv6Only () { | ||
|
||
}, | ||
|
||
unicastHopLimit () { | ||
|
||
}, | ||
|
||
setUnicastHopLimit () { | ||
|
||
}, | ||
|
||
receiveBufferSize () { | ||
|
||
}, | ||
|
||
setReceiveBufferSize () { | ||
|
||
}, | ||
|
||
sendBufferSize () { | ||
|
||
}, | ||
|
||
setSendBufferSize () { | ||
|
||
}, | ||
|
||
nonBlocking () { | ||
|
||
}, | ||
|
||
setNonBlocking () { | ||
|
||
} | ||
}; | ||
|
||
export const udpCreateSocket = { | ||
createTcpSocket () { | ||
|
||
} | ||
}; | ||
import { WasiSockets } from "./sockets/wasi-sockets.js"; | ||
|
||
export const { | ||
ipNameLookup, | ||
instanceNetwork, | ||
network, | ||
tcpCreateSocket, | ||
udpCreateSocket, | ||
tcp, | ||
udp, | ||
} = new WasiSockets(); |
Oops, something went wrong.