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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:37:32+00:00 2026-05-26T00:37:32+00:00

Is it possible to read multiple (2 TCP Ports) at the same time? Example:

  • 0

Is it possible to read multiple (2 TCP Ports) at the same time?

Example:

    public void getFeed()
    {
        while(true)
        {
            try 
            {
                if (!isReadableStream()) throw new Exception("not readable Stream");
                recieveMsg = streamReader.ReadLine();

                if(!String.IsNullOrEmpty(recieveMsg))
                {
                    displayConsole(recieveMsg, false);

                }
            }
            catch(Exception ex)
            {
                displayError(ex.Message);
            }
        }
    }

The function above reads 1 port, and i want to read another port, because the server is getting feeds from another server every 1-2 seconds.

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

    You can read as many ports as you like, but you need to use asynchronous reads. You’re currently using synchronous (or “blocking”) calls, which means that your code stops and waits for data to arrive on one port, and can’t do anything else while it is reading.

    Async reads on the other hand mean that when you call the Read method, it starts the read operation and returns to executing your code immediately. Your code continues to run, and at some point in the future (when some data is available) a delegate you have supplied will be called back. It then Ends the read operation to receive the data.

    You can then trigger as many reads as required, and go off and do anything else you want to do (or sit in a busy wait loop) until the results come back in. You just have to pay attention to where the data has come from so that you keep track of the different message streams coming into your application.

    Read up on Asynchronous Stream operations like NetworkStream.BeginRead.

    You’ll find examples easily by searching on ‘C# TCPClient BeginRead’ and similar queries, e.g.

    http://www.albahari.com/nutshell/ch20.aspx

    NetworkStream BeginRead / EndRead

    etc

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

Sidebar

Related Questions

Is it possible to read a Django model's fields' options? For example, with the
Is it possible to have multiple sockets, which can either by TCP or UDP
Is it possible to serve a read-only pdf file to multiple computers in a
Is it possible to have multiple values under the same field in a .csv
Outlook wont let me send multiple drafts at the same time. Is there an
Is it possible to configure multiple database servers (all hosting the same database) to
Is it possible to read a disk directly with .NET? By directly, I mean
Is it possible to read and write Word (2003 and 2007) files in Python
Is it possible to read and write Word (2003 and 2007) files in PHP
Is it possible to read the data in the php $_SESSION array in 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.