Index: /trunk/GnssCenter/thrift/test2/Makefile
===================================================================
--- /trunk/GnssCenter/thrift/test2/Makefile	(revision 4942)
+++ /trunk/GnssCenter/thrift/test2/Makefile	(revision 4942)
@@ -0,0 +1,33 @@
+
+BOOST_DIR  = /usr/include/boost
+THRIFT_DIR = /usr/local/include/thrift
+LIB_DIR    = /usr/local/lib
+DEFS       = -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H
+
+INC        = -I$(THRIFT_DIR) -I$(BOOST_DIR)
+
+GEN_SRC    = ./gen-cpp/myService.cpp \
+             ./gen-cpp/myservice_types.cpp ./gen-cpp/myservice_constants.cpp
+
+GEN_OBJ    = $(patsubst %.cpp,%.o, $(GEN_SRC))
+
+
+.PHONY: all clean
+
+all: gen-cpp server client
+
+gen-cpp: myservice.thrift
+	thrift -r -gen cpp myservice.thrift
+
+%.o: %.cpp
+	$(CXX) -Wall $(DEFS) $(INC) -c $< -o $@
+
+server: server.o $(GEN_OBJ)
+	$(CXX) $^ -o $@ -L$(LIB_DIR) -lthrift 
+
+client: client.o $(GEN_OBJ)
+	$(CXX) $^ -o $@ -L$(LIB_DIR) -lthrift 
+
+clean:
+	$(RM) *.o server client
+	$(RM) -R gen-cpp
Index: /trunk/GnssCenter/thrift/test2/client.cpp
===================================================================
--- /trunk/GnssCenter/thrift/test2/client.cpp	(revision 4942)
+++ /trunk/GnssCenter/thrift/test2/client.cpp	(revision 4942)
@@ -0,0 +1,45 @@
+#include <iostream>
+
+#include <thrift/protocol/TBinaryProtocol.h>
+#include <thrift/transport/TSocket.h>
+#include <thrift/transport/TTransportUtils.h>
+
+#include "gen-cpp/myService.h"
+
+using namespace std;
+using namespace boost;
+using namespace apache::thrift;
+using namespace apache::thrift::protocol;
+using namespace apache::thrift::transport;
+
+class myServiceHandler : virtual public myServiceIf {
+ public:
+  myServiceHandler() {}
+  void answer(std::string& answ, const std::string& question) {
+    cout << "Server asks: " << question << endl;
+    answ = "I am well, thanks.";
+  }
+
+};
+
+int main(int argc, char** argv) {
+  int port = 9090;
+  shared_ptr<TSocket>          socket(new TSocket("localhost", port));
+  shared_ptr<TTransport>       transport(new TBufferedTransport(socket));
+  shared_ptr<TProtocol>        protocol(new TBinaryProtocol(transport));
+
+  shared_ptr<myServiceHandler> handler(new myServiceHandler());
+  shared_ptr<TProcessor>       processor(new myServiceProcessor(handler));
+
+  try {
+    transport->open();
+   
+    while (processor->process(protocol, protocol, 0)) {}
+
+    transport->close();
+  } catch (TException& exc) {
+    cout << "Exception: " << exc.what() << endl;
+  }
+
+  return 0;
+}
Index: /trunk/GnssCenter/thrift/test2/myservice.thrift
===================================================================
--- /trunk/GnssCenter/thrift/test2/myservice.thrift	(revision 4942)
+++ /trunk/GnssCenter/thrift/test2/myservice.thrift	(revision 4942)
@@ -0,0 +1,4 @@
+
+service myService {
+   string answer(1:string question)
+}
Index: /trunk/GnssCenter/thrift/test2/server.cpp
===================================================================
--- /trunk/GnssCenter/thrift/test2/server.cpp	(revision 4942)
+++ /trunk/GnssCenter/thrift/test2/server.cpp	(revision 4942)
@@ -0,0 +1,58 @@
+#include <iostream>
+#include <string>
+
+#include <thrift/protocol/TBinaryProtocol.h>
+#include <thrift/server/TSimpleServer.h>
+#include <thrift/transport/TServerSocket.h>
+#include <thrift/transport/TBufferTransports.h>
+
+#include "gen-cpp/myService.h"
+
+using namespace std;
+using namespace boost;
+using namespace ::apache::thrift;
+using namespace ::apache::thrift::protocol;
+using namespace ::apache::thrift::transport;
+using namespace ::apache::thrift::server;
+
+class myServiceHandler : virtual public myServiceIf {
+ public:
+  myServiceHandler() {}
+  void answer(std::string& /* answ */, const std::string& /* question */) {
+    // implemented on the client-side only
+  }
+};
+
+class myServerEventHandler : virtual public TServerEventHandler {
+ public:
+  myServerEventHandler() {};
+  virtual void* createContext(shared_ptr<TProtocol> input,
+                              shared_ptr<TProtocol> output) {
+    void* context = TServerEventHandler::createContext(input, output);
+    cout << "createContext " << context << endl;
+
+    string* str = static_cast<string*>(context);
+    cout << "str = " << str << endl;
+
+    return context;
+  }
+};
+
+int main(int argc, char **argv) {
+  int port = 9090;
+  shared_ptr<myServiceHandler>  handler(new myServiceHandler());
+  shared_ptr<TProcessor>        processor(new myServiceProcessor(handler));
+  shared_ptr<TServerSocket>     serverTransport(new TServerSocket(port));
+  shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+  shared_ptr<TProtocolFactory>  protocolFactory(new TBinaryProtocolFactory());
+
+  TSimpleServer server(processor, serverTransport, 
+                       transportFactory, protocolFactory);
+
+  shared_ptr<TServerEventHandler> eventHandler(new myServerEventHandler());
+  server.setServerEventHandler(eventHandler);
+
+  server.serve();
+  return 0;
+}
+
