thrift协议
㈠ 怎么查看thrift 通信协议
最近需要用到Thrift接口, 是Facebook开发的apache开源项目,公司要用,研究了一下 所以写了个PHP调用Thrift的方法事例回 以下是代码,以免以后答别人再走弯路 我是在Yii框架中实现的,和原生代码应该是一样的 官方下载包里也有PHP调用Thrift的例子
㈡ android/java 怎样用 thrift 协议向服务端发送消息
[plain] view plain
namespace java service.test
service Demo {
string sayWord(1:string word)
}
DemoService.java
[java] view plain
package service.test;
import org.apache.thrift.TException;
import service.test.Demo.Iface;
public class DemoService implements Iface {
@
public String sayWord(String word) throws TException {
System.out.println("receive " + word);
return "hello " + word;
}
}
MyServer.java
[java] view plain
package service.test;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.server.TThreadPoolServer.Args;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;
public class MyServer {
public void startServer() {
try {
TServerSocket serverTransport = new TServerSocket(8989);
Demo.Processor process = new Demo.Processor(new DemoService());
Factory portFactory = new TBinaryProtocol.Factory(true, true);
Args args = new Args(serverTransport);
args.processor(process);
args.protocolFactory(portFactory);
TServer server = new TThreadPoolServer(args);
server.serve();
} catch (TTransportException e) {
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyServer server = new MyServer();
server.startServer();
}
}
Client.java
[java] view plain
package service.test;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
public class Client {
public void startClient() {
TTransport transport;
try {
transport = new TSocket("localhost", 8989);
TProtocol protocol = new TBinaryProtocol(transport);
Demo.Client client = new Demo.Client(protocol);
transport.open();
System.out.println(client.sayWord("welcome to use thrift..."));
transport.close();
} catch (TTransportException e) {
e.printStackTrace();
} catch (TException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Client client = new Client();
client.startClient();
}
}
㈢ 什么是金融衍生品
金融衍生品(derivatives),是指一种金融合约,其价值取决于一种或多种基础资产或版指数,权合约的基本种类包括远期、期货、掉期(互换)和期权。金融衍生品还包括具有远期、期货、掉期(互换)和期权中一种或多种特征的混合金融工具。
㈣ 直接打印thrift协议解析出的某个字段为什么打印出的是内存地址
1、用mysql_connnect函数连接数据库2、mysql_query()发送sql语句比如查某字段的值。selectsexfromuserwhereid='uu657'翻译:从表回user中查找id为答uu657的用户的sex性别返回资源结果集。3、mysql_fetch_rows()等函数还有其他的三个,解析2步骤的结果。就ok了