package main
import (
"net"
)
type byteArray []byte
func clientFactory(client net.Conn) {
//buff := make([]byte, 100)
client.Write(byteArray("HTTP/1.1 200 OK\n\nHello World!!"))
println("send message!!")
client.Close()
}
func main() {
if ln, err := net.Listen("tcp", ":8080"); err == nil {
defer ln.Close()
for {
conn, _ := ln.Accept()
println("client login in!")
go clientFactory(conn)
}
}
}
有疑问加站长微信联系(非本文作者)