Implement sock_accept
With the addition of `sock_accept()` in `wasi-0.11.0`, wasmtime can now
implement basic networking for pre-opened sockets.
For Windows `AsHandle` was replaced with `AsRawHandleOrSocket` to cope
with the duality of Handles and Sockets.
For Unix a `wasi_cap_std_sync::net::Socket` enum was created to handle
the {Tcp,Unix}{Listener,Stream} more efficiently in
`WasiCtxBuilder::preopened_socket()`.
The addition of that many `WasiFile` implementors was mainly necessary,
because of the difference in the `num_ready_bytes()` function.
A known issue is Windows now busy polling on sockets, because except
for `stdin`, nothing is querying the status of windows handles/sockets.
Another know issue on Windows, is that there is no crate providing
support for `fcntl(fd, F_GETFL, 0)` on a socket.
Signed-off-by: Harald Hoyer <harald@profian.com>
This commit is contained in:
@@ -189,6 +189,10 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
|
||||
async fn writable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
|
||||
async fn sock_accept(&mut self, fdflags: FdFlags) -> Result<Box<dyn WasiFile>, Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
}
|
||||
|
||||
/// A virtual pipe write end.
|
||||
@@ -348,4 +352,8 @@ impl<W: Write + Any + Send + Sync> WasiFile for WritePipe<W> {
|
||||
async fn writable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
|
||||
async fn sock_accept(&mut self, fdflags: FdFlags) -> Result<Box<dyn WasiFile>, Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user