예제 #1
0
func main() {

	var trans thrift.TTransport

	var host = "127.0.0.1"
	var port = 7366

	addr, err := net.ResolveTCPAddr("tcp", fmt.Sprint(host, ":", port))
	if err != nil {
		fmt.Fprint(os.Stderr, "Error resolving address", err.Error())
		os.Exit(1)
	}
	//	trans, err = thrift.NewTNonblockingSocketAddr(addr)
	trans = thrift.NewTSocketAddr(addr)

	defer trans.Close()

	var protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()

	client := trancam.NewTrancamServerClientFactory(trans, protocolFactory)
	if err = trans.Open(); err != nil {
		fmt.Fprint(os.Stderr, "Error opening socket ", host, ":", port, " ", err)
		os.Exit(1)
	}

	client.Ping(&trancam.Ping{2194})
	rv, _ := client.Mul(50, 5)
	fmt.Println("rv: ", rv)

}
예제 #2
0
func main() {

	var trans thrift.TTransport

	var host = "127.0.0.1"
	var port = 7366

	addr, err := net.ResolveTCPAddr("tcp", fmt.Sprint(host, ":", port))
	if err != nil {
		fmt.Fprint(os.Stderr, "Error resolving address", err.Error())
		os.Exit(1)
	}
	//	trans, err = thrift.NewTNonblockingSocketAddr(addr)
	trans = thrift.NewTSocketAddr(addr)

	trans.Open()

	defer trans.Close()

	framedTransport := thrift.NewTFramedTransport(trans)
	var protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
	protocol := protocolFactory.GetProtocol(framedTransport)

	processor := trancam.NewTrancamServerProcessor(NewTrancamHandler())

	//go func(){
	for {
		_, err := processor.Process(protocol, protocol)
		if err != nil {
			fmt.Println("error ", err)
			break
		}
	}
	//}()
}