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

  • Home
  • SEARCH
  • 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 4253972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:01:09+00:00 2026-05-21T05:01:09+00:00

I have a server with multiple threads. Here is my server connection: while (true)

  • 0

I have a server with multiple threads. Here is my server connection:

while (true) {
    client = this.tcpListener.AcceptTcpClient();
    sThread a = new sThread(form1, listaThreads);

    lock(Program.lockThreads) {
            listaThreads.Add(a);
    }
    Thread clientThread =
        new Thread(new ParameterizedThreadStart(a.HandleClientComm));
    clientThread.Start(client);
}

In my sThread class I have the following code:

public void HandleClientComm(object client)
{
    String a = "";

    try // nu uita sa pui inapoi!
    {
            tcpClient = (TcpClient) client;
            clientStream = tcpClient.GetStream();
            sr = new StreamReader(clientStream);
            sw = new StreamWriter(clientStream);

            a = sr.ReadLine();
    ...

But in some cases I get an error at a = sr.ReadLine(); that says the following: screenshot

What can it be?

  • 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-21T05:01:10+00:00Added an answer on May 21, 2026 at 5:01 am

    Sometimes remote hosts reboot, or the user kills the client program, or routers reboot losing their state and drop all the connections that they used to carry.

    Handling client disconnects is just part of programming reliable software, and you should handle this System.Net.Sockets.SocketException by cleaning up whatever state you have stored for the client and moving on.

    Of course, if you also wrote the client software and your users say it is giving similar error messages, then you should investigate further. 🙂

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

Sidebar

Related Questions

I am new to TCP programming so here is a few simple questions: Client
I already wrote here about the http chat server I want to create: Alternative
We have a SQL Server database table that consists of user id, some numeric
i am creating a bluetooth based server program in Bluez which basically handles connections
Here I am dealing with a database containing tens of millions of records. I
I have a web service I'm trying to load test. I created a program
What's the most appropriate way to detect if a socket has been dropped or
Hello ladies and gents, I'm having a bit of problem with accept() . I
I've got a struts2 action that responds to an AJAX request by taking some
Are these actually three different concepts or am I getting jumbled? (I've been reading

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.