public static object OpenTcpInputOutputPort(object host, object port, object maybetranscoder) { TcpClient tcp = new TcpClient(); tcp.Connect(RequiresNotNull <string>(host), RequiresNotNull <int>(port)); NetworkStream ns = tcp.GetStream(); if (maybetranscoder is R6RS.Transcoder) { R6RS.Transcoder tc = maybetranscoder as R6RS.Transcoder; return(new R6RS.CustomTextReaderWriter( SymbolTable.StringToObject(string.Format("#<tcp-textual-input/output-port {0}:{1}>", host, port)), new StreamReader(ns, tc.codec), new StreamWriter(ns, tc.codec))); } else { return(ns); } }
public static object OpenFileInputOutputPort(object filename, object fileoptions, object buffermode, object maybetranscoder) { string fn = RequiresNotNull <string>(filename); FileOptions fo = ToFileOptions(fileoptions); FileMode fm = GetMode(fo, fn); Transcoder tc = maybetranscoder as Transcoder; bool blockbuffer = buffermode == SymbolTable.StringToObject("block"); try { Stream s = File.Open(fn, fm, FileAccess.ReadWrite); if (blockbuffer) { s = new BufferedStream(s); } if (tc == null) { return(s); } else { return(TranscodedInputOutputPort(s, tc)); } } catch (Continuation) { throw; } catch (FileNotFoundException ex) { return(FileNotFoundViolation("open-file-input/output-port", ex.Message, filename)); } catch (Exception ex) { return(AssertionViolation("open-file-input/output-port", ex.Message, filename)); } }
public TranscodedReader(Stream s, Transcoder tc) { this.tc = tc; this.port = s; }
public TranscodedWriter(Stream s, Transcoder tc) { NewLine = "\n"; this.tc = tc; this.port = s; }
static Transcoder() { native = new Transcoder(); }
public NonBufferedTranscodedReader(Stream s, Transcoder tc) { this.tc = tc; this.port = s; }
public TranscodedReader(Stream s, Transcoder tc) : base(s, tc.codec, true) { this.tc = tc; this.port = s; }