TCP echo server

This commit is contained in:
Meutel 2017-07-09 15:15:38 +02:00
parent a308cd85e0
commit c5fc33b751
2 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -46,3 +46,4 @@ statecsv2json/statecsv2json
converter-main/converter-main converter-main/converter-main
tcpclient/tcpclient tcpclient/tcpclient
tcpserver/tcpserver tcpserver/tcpserver
echoserver/echoserver

23
echoserver/main.go Normal file
View File

@ -0,0 +1,23 @@
package main
import (
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":9000")
if err != nil {
panic(err)
}
defer ln.Close()
for {
conn, err := ln.Accept()
if err != nil {
panic(err)
}
io.Copy(conn, conn)
conn.Close()
}
}