dexter
dexter

Reputation: 31

Thrift client-server multiple roles

this is my first question, so sorry if the form is wrong!

I'm trying to make thrift server (python) and client (c++). However I need to exchange messages in both direction. Client should register (call server's function and wait), and server should listen on same port for N (N-> 100k) incoming connections (clients). After some conditions are satisfied, server needs to call functions on each client and collect results and interpret them.

I'm little confused, and first questions is "can this be done in Thrift"? Second question is related to mechanism that will allow me bidirectional communication. I guess that I will need two services. One with client's functions other with server's. But I'm confused with calling code. I understand one way communication (calling functions from server), but with calling functions from client side I have a problem.

Any suggestions???

Thanks!

Upvotes: 3

Views: 3011

Answers (2)

Nikhil Jindal
Nikhil Jindal

Reputation: 11

Since, you say you are having problem with calling functions from client side, here is a sample Thrift code with Java server and C++ client, where the client calls a function in server. http://fundoonick.blogspot.com/2010/06/sample-thrift-program-for-server-in.html

Hope this helps :)

Upvotes: 1

Artem Sokolov
Artem Sokolov

Reputation: 13691

Consider using boost::asio for your client side, though depending on your level of C++, the code may seem too dense.

If you're looking for a simple example, take a look at: http://www.linuxhowtos.org/C_C++/socket.htm

It contains both server-side and client-side code. Both sides create a socket and two-way communication is achieved by each side posting data to the socket. The server side is generally multi-threaded (with one thread per connection). The client side can be implemented as a single-threaded loop that alternates between querying the socket for any incoming information, performing computations, and posting results back to the socket.

Upvotes: 1

Related Questions