Exemple #1
0
func (t TCPHandler) Start() {
	info()
	go fmt.Println(server.TCPServerForever("tcp4", args.Addr, 0, t))
	for !args.End {
		time.Sleep(time.Second)
	}
}
Exemple #2
0
func main() {
	parser := argparse.NewParser()
	parser.Register(&conf)
	parser.Parse(nil)

	var err error
	ipport := net.JoinHostPort(conf.Ip, parse.String(conf.Port))

	if conf.Proto == "tcp" || conf.Proto == "tcp4" || conf.Proto == "tcp6" {
		err = server.TCPServerForever(conf.Proto, ipport, 0, tcp)
	} else if conf.Proto == "udp" || conf.Proto == "udp4" || conf.Proto == "udp6" {
		err = server.UDPServerForever(conf.Proto, ipport, 8192, udp, nil)
	} else {
		fmt.Printf("Don't support the protocol: %v\n", conf.Proto)
	}

	if err != nil {
		fmt.Println(err)
	}
}