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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:29:47+00:00 2026-05-18T00:29:47+00:00

C# .Net application which connects to five different data streams. The data streams are

  • 0

C# .Net application which connects to five different data streams. The data streams are all in the same plaintext format, but have information from different areas. The application creates an array of custom objects, which contains sockets. Each socket connects to its IP/port (same IP, different ports) with no problems. However, when I read data off each socket, I’m getting the same data stream, from the first port number (in range, 10085-10089). For instance, I read data off the socket that’s connected to 10088, but I get data from 10085.

The IP/port is grabbed from a database, so I deleted all but the record for port 10088, so the array created has only one object; there is only one socket connection, to port 10088. But I’m still getting only data from 10085.

I’ve viewed the data from each port through putty; the data is definitely different. Any idea why I’m getting the same data no matter what port a socket’s connected to?

This is some simpler code that replicates the problem:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace MultipleFeedConnectionsTest
{
class Program
{
    static void Main(string[] args)
    {
        Socket[] sockets;
        IPAddress ipAddress;
        IPAddress currentIP;
        int portNumber = 10085;

        ipAddress = IPAddress.Parse("xxx.xxx.xxx.xxx"); // changed the IP
        currentIP = IPAddress.Parse("192.168.5.122");

        sockets = new Socket[5];

        for (int counter = 0; counter < 5; counter++)
        {
            if (counter != 1) 
            {
                sockets[counter] = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                sockets[counter].Bind(new IPEndPoint(currentIP, portNumber + counter));
                sockets[counter].Connect(new IPEndPoint(ipAddress, portNumber + counter));
            }
        }

        while (true) 
        {
            for (int counter = 0; counter < 5; counter++)
            {
                if (counter != 1) 
                {
                    byte[] receivedData = new byte[255];
                    NetworkStream stream = new NetworkStream(sockets[counter]);
                    stream.Read(receivedData, 0, 255);

                    Console.WriteLine("FEED " + (portNumber + counter));
                    Console.WriteLine(Encoding.ASCII.GetString(receivedData));
                }
            }
        }
    }
}
    }

The above code outputs the same data from each socket. Again, when I access these through putty, they are different.

  • 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-18T00:29:47+00:00Added an answer on May 18, 2026 at 12:29 am

    Tried your code and it works just fine.

    You should however get rid of the call to sockets[counter].Bind(……..) because it has nothing to do with your code – at all!!
    Binding is usually done on the listening socket side, not the connecting one.

    Anyway, besides that everything looks normal – I’ve also made sure I’m sending a unique message to each socket..

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

Sidebar

Related Questions

A company I work for develops winforms .net applications in which users are required
I've been searching the net for answers but I can't seem to find a
In my .NET application I am connecting to Microsoft SQL Server 2005 or 2008
am running the asp.net application...am enhancing the already developed project..i want to create the
I'm developing a .NET 2.0 client application that needs to connect to a WCF
I have created a simple JSF application, now must to connect to SQL Server
I am trying to connect a client (which is behind the company's proxy) to
Working on Progress 9.1E on a Windows box. We've got a standard 4GL GUI
I'm trying to send a video stream to a Red5 server using Flex. My
Is there any way I can connect to a local computer from internet website..

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.