Add beej/telnot.go

This commit is contained in:
2025-09-26 19:04:24 +09:00
parent 87fce8bab5
commit 0df62464c6

18
beej/telnot.go Normal file
View 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)
}
}