Dart passes TCP ServerSocket client for isolation

On Quor, Seth Ladd once said:

Consider accepting new compounds and giving them isolates to get the job done. As of today, you can transfer sockets to other isolates (by reference) and scale linearly.

I tried to do it in different ways and each one of them failed. My code:

ServerSocket.bind("127.0.0.1", 5555).then((ServerSocket socket) {
    socket.listen((client) {
        Isolate.spawn(SomeClient.start, client);
    });
});

      

Throws the same exception every time.

Illegal argument(s): Illegal argument in isolate message : (object extends NativeWrapper)

      

Receiving a stream from a socket gives the same result. Does anyone know how I can accomplish what Seth said?

+3


source to share


1 answer


The only thing I found was the opposite of what I thought should work

https://groups.google.com/a/dartlang.org/forum/#!topic/misc/G9wYnvSG0UQ



Here the ServerSocket is forwarded to other isolators, and incoming connections are shared equally with the isolated ones listening on that port.

The discussion also mentions that it does not support passing connections, but only server sockets and passing connections are not the closest target.

+2


source







All Articles