I have my c++ client application and Java server. The client app connects and send data to the server.
For example I send integer value:
boost::shared_ptr<TSocket> socket(new TSocket(hostMS, portMS));
boost::shared_ptr<TFramedTransport> transport(new TFramedTransport(socket));
boost::shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
transport->open();
protocol->writeI32(0xCA12EEAA);
transport->writeEnd();
transport->flush();
The server side code is:
int nMagic =0;
// int nLen = in.readInt(); <------------here is I read the length
int ch1 = in.read();
int ch2 = in.read();
int ch3 = in.read();
int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
nMagic = ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
The question is: When I added one more read integer (see my comment) it works ok. First of all i read the length (4 bytes) and then data - integer.
It means that the client sends length (int) data (int)
but server reads only data.
How I can send data only? I can use another thrift transport or protocol or use non-thrift library...
But if you use non-blocking sever ,then you must use TFramededTransport