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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:23:31+00:00 2026-05-30T00:23:31+00:00

What would you recommend I do to buffer multiple streams (each stream would require

  • 0

What would you recommend I do to buffer multiple streams (each stream would require it’s own buffer) in C?

I sort of put together a solution in my head:

This is theoretical “pseudo code”

[ptr, ptr, ptr, ptr ... ]

Each ptr is a pointer to a struct:

{
    stream_id
    buff_ptr
}

stream_id is the ID of the stream (I have that information) and the buff_ptr is a pointer to some malloced data. Also, the buffers would probably have to be flexible and it’d have to call malloc and free a lot to make it flexible (at least I think it would?

I would basically find the buffer I need by iterating through the array of ptrs.


So, is that “architecture” good, or is there a better one?

If anyone is wondering “Why the nyan does she need that?!” I’ve made a server in Ruby/EventMachine, the protocol is really rotten (to say the least) and I don’t know how else to handle it… Unless there’s a way to force EventMachine to buffer it for me, that would be the best solution, I suppose.

Thanks.

P.S: Sorry for the rave! ~

  • 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-30T00:23:33+00:00Added an answer on May 30, 2026 at 12:23 am

    Well, it seems the only option but you can change a few things:

    • Don’t malloc and free. Use realloc instead
    • Iterating through the list could be OK but if there are a lot of buffers

      • Can you make the caller pass you a pointer to the buffer ?
      • Can you use a hash instead of a list and search by stream_id ? For example glib2 provides such a hash

    Many APIs (for example epoll) allow you to associate a pointer with an id (a descriptor in the case of epoll). When something interesting happens to that id, the API passes you your pointer -> zero search at the expense of 4-8 bytes of memory.

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

Sidebar

Related Questions

I've not seen anything in this area I would recommend to a client. If
So standard Agile philosophy would recommend making your domain classes simple POCOs which are
Which orm you would recommend for a beginner moving from ado.net?... Thus far used
Are there any tools you would recommend for site architecture design and analysis? I've
Is there a guide/reference anyone would recommend to pick up C++ specifically if you
What are the basic minimum set of Code Analysis rules that you would recommend
Has someone experience with database comparison tools? Which one you would recommend? We are
Would you recommend me the best approach to edit SQL query with Visual Studio
Would you recommend using a datetime or a timestamp field, and why (using MySQL)?
What would you recommend for OS X development of a graphical application like those

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.