448
return { stream: socket, leftover };
449
}
451
>
// Generic ISocket (e.g. a managed/exec-server connection). Read the
452
>
// buffered leftover and detach the protocol's reader/writer before the
453
>
// adapter starts consuming the socket, so subsequent messages reach the
454
>
// adapter exactly once. This all runs synchronously, so no message can
455
>
// arrive in the gap and be lost.
456
>
const leftover = protocol.readEntireBuffer();
457
>
protocol.dispose();
458
>
return { stream: new RemoteSocketStream(remoteSocket), leftover };
459
}
460