TCP echo server
This commit is contained in:
parent
a308cd85e0
commit
c5fc33b751
1
.gitignore
vendored
1
.gitignore
vendored
@ -46,3 +46,4 @@ statecsv2json/statecsv2json
|
||||
converter-main/converter-main
|
||||
tcpclient/tcpclient
|
||||
tcpserver/tcpserver
|
||||
echoserver/echoserver
|
||||
|
23
echoserver/main.go
Normal file
23
echoserver/main.go
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user