Beispiel #1
0
func main() {
	parser := argparse.NewParser()
	parser.Register(&args)
	parser.Parse(nil)

	if args.Ssize < 64 || args.Ssize > 32768 {
		args.Ssize = 1024
	}

	if args.Rsize < 1024 || args.Rsize > 65535 {
		args.Rsize = 8192
	}

	if args.Rate != 0 {
		rate := args.Rate * 1024 / 8                   // Convert MBit/s to KByte/s
		args.TB = tbucket.NewTokenBucket(uint64(rate)) // 1 token stands for 1KB/s
		args.TB.Start()
	}

	args.Addr = net.JoinHostPort(args.Ip, args.Port)

	fmt.Printf("%+v\n", args)
	server.Debug = true
	//argparse.Debug = true

	tcp := TCPHandler{}
	tcp.Start()
}
Beispiel #2
0
func main() {
	parser := argparse.NewParser()
	parser.Register(&conf)
	parser.Parse(nil)

	ipport := net.JoinHostPort(conf.Ip, parse.String(conf.Port))
	if conf.Proto == "tcp" || conf.Proto == "tcp4" || conf.Proto == "tcp6" {
		tcp(conf.Proto, ipport)
	} else if conf.Proto == "udp" || conf.Proto == "udp4" || conf.Proto == "udp6" {
		udp(conf.Proto, ipport)
	} else {
		fmt.Printf("Don't support the protocol: %v\n", conf.Proto)
	}
}
Beispiel #3
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)
	}
}
Beispiel #4
0
func main() {
	parser := argparse.NewParser()
	parser.Register(&args)
	parser.Parse(nil)

	if args.Ssize < 64 || args.Ssize > 32768 {
		args.Ssize = 1024
	}

	if args.Rsize < 1024 || args.Rsize > 65535 {
		args.Rsize = 8192
	}

	if args.Rate != 0 {
		rate := args.Rate * 1024 / 8                   // Convert MBit/s to KByte/s
		args.TB = tbucket.NewTokenBucket(uint64(rate)) // 1 token stands for 1KB/s
		args.TB.Start()
	}

	args.Addr = net.JoinHostPort(args.Ip, args.Port)
	info()
	h := TcpClient{}
	h.Start()
}