import { NetSocketOptions } from '.' ; import { BiStream } from '../../stream' ; export class DenoSocket implements BiStream { private _ended : boolean ; constructor ( private _conn ) { this . _ended = false ; } get ended ( ) : boolean { return this . _ended ; } read ( buffer ) { return this . _conn . read ( buffer ) ; } write ( data ) { return this . _conn . write ( data ) ; } close ( ) { this . _conn . close ( ) ; this . _ended = true ; } static async connect ( option ) { return new DenoSocket ( await Deno . connect ( { hostname : option . host , port : option . port } ) ) ; } static async connectTls ( option ) { return new DenoSocket ( await Deno . connectTls ( { hostname : option . host , port : option . port } ) ) ; } }