Efficiently sending protocol buffer messages with http on an android platform

Posted by Ben Griffiths on Stack Overflow See other posts from Stack Overflow or by Ben Griffiths
Published on 2010-03-16T20:53:28Z Indexed on 2010/03/16 22:01 UTC
Read the original article Hit count: 254

Filed under:
|
|

I'm trying to send messages generated by Google Protocol Buffer code via a simple HTTP scheme to a server. What I have currently have implemented is here (forgive the obvious incompletion...):

 HttpClient client = new DefaultHttpClient();
 String url = "http://192.168.1.69:8888/sdroidmarshal";
 HttpPost postRequest = new HttpPost(url);

 String proto = offers.build().toString();
 List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
 nameValuePairs.add(new BasicNameValuePair("sdroidmsg", proto));

 postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));

 try {
   ResponseHandler<String> responseHandler = new BasicResponseHandler();
   String responseBody = client.execute(postRequest, responseHandler);

 } catch (Throwable t) {

 }

I'm not that experienced with communications over the internet and no more so with HTTP - while I do understand the basics... So my question, before I blindly develop the rest of the application around this, is whether or not this is particularly efficient? I ideally would like to keep messages small and I assume toString() adds some unnecessary formatting.

© Stack Overflow or respective owner

Related posts about android

Related posts about protocol-buffers