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了