/* Copyright (C) 2014 by Alexandru Cojocaru */ /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package main import ( "io" "log" "net" "os" ) func main() { log.SetFlags(log.Lshortfile) con, err := net.Dial("tcp", ":7") if err != nil { log.Fatal(err) } _, err = io.Copy(con, os.Stdin) if err != nil { log.Fatal(err) } if tcpcon, ok := con.(*net.TCPConn); ok { tcpcon.CloseWrite() } _, err = io.Copy(os.Stdout, con) if err != nil { log.Fatal(err) } err = con.Close() if err != nil { log.Fatal(err) } }