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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:02:23+00:00 2026-05-16T16:02:23+00:00

I have a server thats sending out data records as strings of varying length(for

  • 0

I have a server thats sending out data records as strings of varying length(for eg, 79,80,81,82)

I want to be able to receive exactly one record at a time.I’ve delimited records with a (r) but because I dont know howmany bytes I have to receive, It sometimes merges records and makes it difficult for me to process.

  • 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-16T16:02:23+00:00Added an answer on May 16, 2026 at 4:02 pm

    I have two ideas for you:

    1. Use XML for the protocol. This way you know exactly when each message ends.
    2. Send in the header of each “packet” the packet size, this way you know how much to read from the socket for this specific packet.

    Edit:
    Look at this dummy code for (2)

    int buffer_size;
    char* buffer;
    
    read( socket, &buffer_size, sizeof(buffer_size)); 
    buffer = (char*) malloc(packet_size);
    read( socket, buffer, buffer_size );
    // do something
    free( buffer) ; 
    

    EDIT:
    I recommend looking at the comments here, as they note that the contect might not be ready by a simple “read()”, you need to keep “read()”ing, until you get the correct buffer size.

    Also – you might not need to read the size. Basically you need to look for the ending top level tag of the XML. This can be done by parsing the whole XML, or parlty parsing the XML you get from the stream untill you have 0 nodes “open”.

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

Sidebar

Related Questions

I have this TCP server that I want to be able to receive numbers
I have a socket server, written in C++ using boost::asio, and I'm sending data
I have a server that streams data out on a TCP port once you
I have a sentry server that works ok. raven test <dnstoserver> -> Sending a
I have an IPhone app that uses webservices to get data from a server.
I have a client submitting a web-request (POST) of XML data to a server.
OK, so I have a socket InputStream over which the server is sending a
I have a socket server that is supposed to receive UTF-8 valid characters from
I have been trying to work out an issue with Sagepay server intergration into
I have a client-side script written in jQuery that is sending text/xml data to

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.