try { host = args[0] port = args[1].toInteger() } catch (e) { println "usage: groovy ${this.class.name} host port" System.exit 1 } new Socket(host, port).withStreams { is, os -> dis = new DataInputStream(is) buf = new byte[1024] while ((len = System.in.read(buf)) >= 0) { os.write(buf, 0, len) dis.readFully(buf, 0, len) System.out.write(buf, 0, len) } }