lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.11k stars 74 forks source link

Unable to compile via webassembly. #97

Closed entropylost closed 3 years ago

entropylost commented 3 years ago

I get a bunch of these errors when attempting to compile via webassembly:

error[E0599]: no method named `as_sock` found for reference `&TcpStream` in the current scope
   --> /home/blah/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.37/src/ext.rs:690:22
    |
690 |         get_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF).map(int2usize)
    |                      ^^^^^^^ method not found in `&TcpStream`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `AsSock` defines an item `as_sock`, perhaps you need to implement it

It seems like net2 does not work on wasm.

lemunozm commented 3 years ago

I will try after https://github.com/lemunozm/message-io/issues/96 be resolved. Thanks for notifying!

lemunozm commented 3 years ago

This issue is due because the browsers do not support creating TCP streams directly. The web-sys must be used instead. Tracking this feature here https://github.com/lemunozm/message-io/issues/100