First commit
This commit is contained in:
parent
b378377069
commit
deb52470e5
5 changed files with 134 additions and 0 deletions
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
const HOST = "localhost"
|
||||
const PORT = "8080"
|
||||
|
||||
// Hello returns a greeting for the named person.
|
||||
func main() {
|
||||
|
||||
go startServer()
|
||||
time.Sleep(1 * time.Second)
|
||||
client := StartClient()
|
||||
|
||||
closeConnection("Client", client)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
func log(msg string) {
|
||||
fmt.Println(time.Now().Format(time.RFC822) + " " + msg)
|
||||
}
|
||||
|
||||
func closeConnection(id string, conn net.Conn) {
|
||||
log(id + " connection closed: " + conn.LocalAddr().String())
|
||||
conn.Close()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue