[ https://issues.apache.org/jira/browse/THRIFT-976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13112418#comment-13112418 ]
Aurélien Revol edited comment on THRIFT-976 at 9/22/11 11:08 AM: ----------------------------------------------------------------- Hi all, As I've been playing a bit with the c_glib library, I've managed to port some C++ client code to the Glib and get a half-working solution. There must be something wrong in my initialization code (directly translated from the C++ tutorial to the Glib), since I can send requests, but not receive them. (It only works if I tweak the "len" variable in the "thrift_socket_read" function in "thrift_socket.c" while running in the debugger!) I'm willing to contribute a port of the tutorial to the c_glib, provided somebody helps me with the following initialization and cleanup code: {code:title=c_glib_client.c|borderStyle=solid} #include "protocol/thrift_protocol.h" #include "protocol/thrift_binary_protocol.h" #include "transport/thrift_buffered_transport.h" #include "transport/thrift_transport.h" #include "transport/thrift_socket.h" #include "../gen-c_glib/calculator.h" int main(int argc, char** argv) { ThriftSocket *tsocket = THRIFT_SOCKET( g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", "port", 9090, 0) ); ThriftTransport *transport = THRIFT_TRANSPORT( g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport", tsocket, 0) ); ThriftProtocol *protocol = THRIFT_PROTOCOL ( g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, 0) ); CalculatorClient *client = CALCULATOR_CLIENT( g_object_new(TYPE_CALCULATOR_CLIENT, "input_protocol", protocol, /* ??? */ "output_protocol", protocol, 0) ); CalculatorIf *service = CALCULATOR_IF(client); thrift_transport_open(transport, 0); /* Real user code here */ thrift_transport_close(m_transport, 0); g_object_unref (client); g_object_unref (protocol); g_object_unref (transport); g_object_unref (tsocket); return 0; } {code} Thanks for any help! was (Author: arevol): Hi all, As I've been playing a bit with the c_glib library, I've managed to port some C++ client code to the Glib and get a half-working solution. There must be something wrong in my initialization code (directly translated from the C++ tutorial to the Glib), since I can send requests, but not receive them. (It only works if I tweak the "len" variable in the "thrift_socket_read" function in "thrift_socket.c" while running in the debugger!) I'm willing to contribute a port of the tutorial to the c_glib, provided somebody helps me with the following initialization and cleanup code: {code:title=c_glib_client.c|borderStyle=solid} #include "protocol/thrift_protocol.h" #include "protocol/thrift_binary_protocol.h" #include "transport/thrift_buffered_transport.h" #include "transport/thrift_transport.h" #include "transport/thrift_socket.h" #include "../gen-c_glib/calculator.h" int main(int argc, char** argv) { ThriftSocket *tsocket = THRIFT_SOCKET( g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", "port", 9090, 0) ); ThriftTransport *transport = THRIFT_TRANSPORT( g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport", tsocket, 0) ); ThriftProtocol *protocol = THRIFT_PROTOCOL ( g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, 0) ); CalculatorClient *client = CALCULATOR_CLIENT( g_object_new(TYPE_CALCULATOR_CLIENT, "input_protocol", protocol, /* ??? */ "output_protocol", protocol, 0) ); CalculatorIf *service = CALCULATOR_IF(client); thrift_transport_open(transport, 0); /* Real user code here */ thrift_transport_close(m_transport, 0); g_object_unref (client); g_object_unref (protocol); g_object_unref (transport); g_object_unref (tsocket); } {code} Thanks for any help! > c_glib tutorial > --------------- > > Key: THRIFT-976 > URL: https://issues.apache.org/jira/browse/THRIFT-976 > Project: Thrift > Issue Type: Improvement > Components: C glib - Compiler, C glib - Library, Tutorial > Reporter: Roger Meier > Assignee: Michael Lum > Priority: Minor > > It would be great to have a tutorial for the brand new c_glib library. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira