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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:35:34+00:00 2026-05-23T17:35:34+00:00

i have a GPS device that will be installed in many trucks. i can

  • 0

i have a GPS device that will be installed in many trucks.
i can configure the device to send data statement “gps data, device id” over gprs to IP and Port.
i’m using TcpListener class to read the data on the server side.

TcpListener server = null;
private void listen_data()
{
    Int32 port = controller_port;
    IPAddress localAddr = IPAddress.Parse(this_ip);
    server = new TcpListener(localAddr, port);
    server.Start();
    Byte[] bytes = new Byte[256];
    String data = null;
    while (true)
    {
        Console.Write("Waiting for a connection...-- ");
        TcpClient client = server.AcceptTcpClient();
        Console.Write("Connected!");
        data = null; int i;
        NetworkStream stream = client.GetStream();
        while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
        {
            data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
        }
    }
}

that method is listening to what is coming on server ip and port.

  1. i want to know if i configured the devices to send to the server on the same port.am i able to listen to all the devices or the first device to connect will be the only one ?

  2. is this method the the best way to read the coming data from the devices?

  3. do i need to configure a different port for each device and create a new listen thread for each device port?

  4. sometimes i’m facing exceptions “the request channel timed out while waiting for a reply”

many thanks in advance for your help.

  • 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-23T17:35:34+00:00Added an answer on May 23, 2026 at 5:35 pm

    In your code you are listening to the all devices but only after finish read all data from the first device so you are receiving “the request channel timed out while waiting for a reply”.You should have a different threads each one handle a tcpClient.

    so the code should be something like:

    TcpListener server = null;
    private void listen_data()
    {
        Int32 port = controller_port;
        IPAddress localAddr = IPAddress.Parse(this_ip);
        server = new TcpListener(localAddr, port);
        server.Start();
        while (true)
        {
            Console.Write("Waiting for a connection...-- ");
            TcpClient client = server.AcceptTcpClient();
            Console.WriteLine("new client connected");
            ThreadPool.QueueUserWorkItem(new WaitCallback(HandleClient), client);//or use Task if 4.0 or new Thread...
        }
    }
    
    private void HandleClient(object tcpClient)
    {
        TcpClient client = (TcpClient)tcpClient;
        Byte[] bytes = new Byte[256];
        String data = null;
        int i;
    
        NetworkStream stream = client.GetStream();
        while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
        {
            data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
        }
    
        Console.WriteLine(data);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gps device that records data e.g. datetime, latitude, longitude I have
The application that I have in the works uses GPS data to mark files
I have a java application that stores some GPS data in a strange format:
I have an app that does a query to a database.....asking for GPS data
I'm working on asset tracking application. I have devices that send update on GPS
I have a problem I can not solve, when the GPS data logger is
I have a number of tracks recorded by a GPS, which more formally can
Say you have a Windows Mobile 6.0 phone that also has a GPS receiver.
I have a task to store large amount of gps data and some extra
My gps device writes its data to a text file in my server. Now

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.