init
This commit is contained in:
commit
8e8f98df6c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.idea
|
42
cmd/smoketest.go
Normal file
42
cmd/smoketest.go
Normal file
@ -0,0 +1,42 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
connHost = "localhost"
|
||||
connPort = "3030"
|
||||
connType = "tcp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l, err := net.Listen(connType, connHost+":"+connPort)
|
||||
if err != nil {
|
||||
fmt.Printf("net.Listen fail: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer l.Close()
|
||||
|
||||
fmt.Println(fmt.Sprintf("Listening on %s:%s", connHost, connPort))
|
||||
|
||||
for {
|
||||
conn, err := l.Accept()
|
||||
if err != nil {
|
||||
fmt.Printf("Error accepting: %v\n", err)
|
||||
}
|
||||
go handleRequest(conn)
|
||||
}
|
||||
}
|
||||
|
||||
func handleRequest(conn net.Conn) {
|
||||
buf := make([]byte, 1024)
|
||||
_, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading: %v\n", err)
|
||||
}
|
||||
conn.Write(buf)
|
||||
conn.Close()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user