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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:01:43+00:00 2026-05-20T13:01:43+00:00

I am writing a service that will connect to a single socket then read

  • 0

I am writing a service that will connect to a single socket then read the data which will be continuous and at times plentiful. The data I receive should then be handed off to another thread (in the service) to process, the reason is that the processing might take a while and I don’t want to block the receiving of the socket.

I was going to do this using the Begin or Async receive methods to process the data rather than having a thread running reading a concurrent queue or something. I need this to scale to possibly large amounts of data coming over the socket. Any suggestions?

  • 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-20T13:01:43+00:00Added an answer on May 20, 2026 at 1:01 pm

    I’m not sure how using asynchronous receive is going to help with the processing. As I understand it, you’ll have one thread that connects to the socket and reads a continuous stream of data. I assume that the thread can break that continuous stream into records of some kind, or at least blocks of manageable size. You then have to make that data available to one or more processing threads.

    I would strongly suggest that you do use a concurrent queue (actually a BlockingCollection) to communicate between the thread that’s reading the data and the thread or threads that will be doing the processing. There are several reasons I suggest using BlockingCollection:

    • It’s is easy to use – no explicit locking code
    • It does non-busy waits
    • It handles N readers and N writers efficiently

    Yours is a pretty typical producer/consumer application. The producer (the thread reading the socket) gets data, places it into the queue, and then one or more consumers (processing threads) can read and process the data. I can’t think of a simpler, more effective, or more efficient way to do this in .NET than with a BlockingCollection.

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

Sidebar

Related Questions

I am writing WCF service that uses wsHttpBinding binding, which is not hosted in
I have the following data model: I am writing a WCF service that needs
I'm in the process of writing a WCF service that will allow an ASP.Net
I am thinking about writing a windows service that will turn a certain functionality
I'm writing an XML-RPC service that will be consumed by third parties and was
I am writing a bash script for an automator service that will take a
I am writing a WCF Service that will require a username and password authentication,
I am writing a REST API for a service that will accept user contributed
I'm writing a Windows service that will poll my IMAP4 inbox for emails from
For the first time, I am writing a web service that will call upon

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.