Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:17:45+00:00 2026-05-23T01:17:45+00:00

I implemented on Android a small application that sends through a socket connection strings

  • 0

I implemented on Android a small application that sends through a socket connection strings to a server ( C# ).

For now, I only encode the strings I send ( security issues ), but now I need to implement a protocol to have other features on my App like a “keep alive” message, among others.

The procotol was already defined by us, it has a header ( a sequence of bytes ) and the data ( the strings that I sent before ), but because I am not familiar with this I don’t know how to start implementing on Java ( client ) the protocol.

Could you point some examples of simple protocols implementation? I need to read bytes, so I can decide what type of action the client is asking from the server, and the other way around too.

My first try would be to create one class for each Message type, and fill the bytes the way i need, in the end each message would be a byte array. But I don’t want to start digging on this before I am sure that that’s the right path to go.

Thank you for your time.

EDIT

Ended using Protocol Buffers for implementing this:

http://code.google.com/p/protobuf-net/ – for the c# server side

http://code.google.com/p/protobuf-javame/ – for the Android side

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:17:46+00:00Added an answer on May 23, 2026 at 1:17 am

    I faced the same problem some time ago. If you have enough bandwidth then I suggest you go XML and XML streams, these two technologies fit very well in all platforms and all languages. However, if you are short of bandwidth then yes you can go binary.
    Here is the design I usually use:

    class AbstractMessage{
     byte[] data;
     void GenerateHeader(){
            // this method generates the message header
     }
     // Use this method to translate your 
     // business domain message into a byte array that will go    through the network
     void abstract byte[] ToByteArray(AbstractMessage);
     // Translate received data from network to a business domain message
     void abstract AbstractMessage ParseMessage(byte[] receivedData) 
    }
    
    // And then you can have your messages
    class MyMessage extends AbstractMessage{
     // In this subclass, you can define how a 
     // MyMessage object is translated into a byte array 
     // and vice versa (using ToByteArray and ParseMessage methods)
    }
    

    I hope this helps,

    Regards,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone successfully implemented a Java based solution that uses Microsoft SQL Server 2005
I have an android application that I want to always be running in landscape
Implemented the Sink Class - to receive event notifications from COM Server Event Interface
I implemented a small OOP library in Lua, and two things are not quite
I implemented OpenID support for an ASP.Net 2.0 web application and everything seems to
I implemented threading in my application for scraping websites. After all the sites are
I want to port an small open source AES encryption class to Android, and
I have successfully implemented this from android to a java httpservlet on google app
I have implemented Sliding Drawer in my application using the below XML layout: (I
I implemented a Lucene search solution awhile back, and it got me interested in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.