user3301839
user3301839

Reputation: 23

Dart websocket in dart:io and dart:html

I have seen two implementation of websocket in dart:io and dart:html. Which one should I use? Currently I prefer more the websocket in dart:io since it seems to fit more naturally how dart handle streams and asynchronous programming.

Upvotes: 2

Views: 498

Answers (2)

Kai Sellgren
Kai Sellgren

Reputation: 30292

The dart:html library is used on the client-side and can be compiled to JavaScript.

Use dart:io for server-side code.

In a typical setup, you have a web server listening to WebSocket connections from the client, in which case you would use the one from dart:html. But of course you can also initiate WebSocket connections at the server if you ever need :)

Upvotes: 4

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657977

  • dart:io is only available on the server
  • dart:html is only available in the browser

Upvotes: 3

Related Questions