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 7762397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:23:30+00:00 2026-06-01T14:23:30+00:00

Okay, so my goal is to build a easy to use protocol for sending

  • 0

Okay, so my goal is to build a easy to use protocol for sending data over tcp. basically, it would send a message, and an object(of unknown type) over tcp. To send, it would only require one method call and to receive it would only require one also.

So this is how I was thinking to format the “message”.

length_of_message – “A string that is a message” – length_of_Object – object

length_of_message would be a set number of bytes. along with length_of_Object.

the actual message string and the actual object would be of variable length.

If the actual class of the object wouldn’t be know, could I just declare it as a “generic object” somehow? and then get its class name from the “generic object” and the message would tell the receiver what to do with the object?

It would be simple if it was a constant object type but i want to be able use one send function and one receive function for ever object that needs to be send/recieved.

Any suggestions?

Thanks,
Andrew

  • 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-06-01T14:23:32+00:00Added an answer on June 1, 2026 at 2:23 pm

    Make sure you aren’t reinventing the wheel (unless doing so is your primary goal).

    With that in mind, consider:

    • Implement and use the NSCoding protocol. It allows for the efficient archival of complexly connected object graphs, including cycles.

    • Instead of raw TCP, use HTTP. While it adds a bit over overhead in the headers, the body can be straight encoded data. More importantly, HTTP is ubiquitous. It routes through just about anything whereas other protocols might be blocked (think proxy servers).

    • Via HTTP, you can leverage compression. If one side of your communication pipe is an existing web server of some kind, it probably already supports gzip’d communication. Compressing an NSData (that would be the result of NSCoding) is trivial.

    • Alternatively, stick with straight plists.

    Unless you truly have some requirement that makes the above inviable, you are likely better off leveraging the above technologies instead of rolling a new one.

    With that said, what you propose is fine. I would add, possibly, a structure like:

    [HEADER][MSGID][LEN][TYPE][DATA of len][POST]

    Where the POST is a known sequence of bytes that the receiver can verify to make sure that, maybe, all the data was received correctly. Or you could go whole hog and integrate a checksum. Or sub-pieces could be repeated, as needed (i.e. [LEN][TYPE][DATA] over and over.

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

Sidebar

Related Questions

I would like to have a confirmation on some point. My goal is to
Okay, this should be really simple, but I have searched all over for the
Okay, so I've successfully completed my goal using buttons which was merely a test.
Okay, here goes: the goal is to make regexp that matches BLABLA BLA B
Okay, consider the following classes: class Object { public: // Constructor Object() : [Initialization
Okay so basically I'm trying to do a depth-first search for a mini-peg solitaire
Okay, my situation is such: I need to send the contents of a JavaScript
Okay. I'm sick of this problem. This has to have an easy fix, I'm
Okay, so generally I wouldn't have a problem doing this and it would be
Okay, I want to use one layout and change my strings programatically using the

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.