A TCP half-close, with a FIN? I think that's a limitation of the socket system call API itself.
socket.listen(onData, onDone: onSocketDone);
onSocketDone() {
_closed = true;
}
write(Buffer buffer) {
if (_closed)
throw StateError('Cannot write to socket, it is closed');
...write
}
onData(RawSocketEvent event) {
if (event == RawSocketEvent.READ_CLOSED) {
_closed = true;
}
// Other events handled as well, READ, CLOSED, WRITE
}
But I don't know what's going on under the hood there.