示例#1
0
文件: server.go 项目: houcy/link
func main() {
	var addr string

	flag.StringVar(&addr, "addr", ":10010", "echo server address")
	flag.Parse()

	server, err := link.Serve("tcp", addr, codec.Bytes(codec.Uint16BE))
	if err != nil {
		panic(err)
	}
	println("server start:", server.Listener().Addr().String())
	for {
		session, err := server.Accept()
		if err != nil {
			break
		}
		go io.Copy(session.Conn(), session.Conn())
	}
}
示例#2
0
文件: go_web.go 项目: wangzun/go_web
func main() {
	funnk()
	go tcp_test()
	go func() {
		var addr string

		flag.StringVar(&addr, "addr", ":10010", "echo server address")
		flag.Parse()

		fmt.Println("addr:", addr)

		server, err := link.Serve("tcp", addr, codec.Bytes(codec.Uint16BE))
		if err != nil {
			panic(err)
		}
		println("server start:", server.Listener().Addr().String())
		for {
			session, err := server.Accept()
			if err != nil {
				break
			}
			go io.Copy(session.Conn(), session.Conn())
		}
	}()
	fmt.Println(test1)
	fmt.Println("ssssssssssssssssss")
	test_struct(&test2{})
	test_struct(&test2{})
	test_struct(&test2{})
	test_struct(&test2{})
	test_struct(&test2{})
	http.HandleFunc("/", sayhelloName)
	http.HandleFunc("/login/", login)
	http.HandleFunc("/upload/", upload)
	//	amqp_connect()
	err := http.ListenAndServe(":9099", nil) //设置监听的端口
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}

}