Add beej/telnot.go
This commit is contained in:
18
beej/telnot.go
Normal file
18
beej/telnot.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import ("fmt";"io";"log";"net";"os")
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 3 {
|
||||
log.Fatal("usage: telnot hostname port")
|
||||
}
|
||||
hostname, port := os.Args[1], os.Args[2]
|
||||
if conn, err := net.Dial("tcp", net.JoinHostPort(hostname, port)); err != nil {
|
||||
log.Fatal("failed to connect:", err)
|
||||
} else {
|
||||
defer conn.Close()
|
||||
fmt.Printf("Connected to %s port %s\nHit ^C to exit\n", hostname, port)
|
||||
go io.Copy(conn, os.Stdin)
|
||||
io.Copy(os.Stdout, conn)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user