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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:08:05+00:00 2026-05-27T21:08:05+00:00

I have a multi-threaded console application acting as a server. The server spawns a

  • 0

I have a multi-threaded console application acting as a server. The server spawns a new thread every time a new client connects to the TcpListener:

//code copied from http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-  threaded-tcp-server
//blocks until a client has connected to the server
TcpClient client = tcpListener.AcceptTcpClient();  
//create a thread to handle communication with connected client
Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
                clientThread.Start(client);

The thread makes a number of HttpWebRequests using the following code:

public static HttpWebResponse HttpGet(string pRequestURI, string pArgs)
{
    string requestURI = string.Format("{0}?{1}", pRequestURI, pArgs);
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURI);
    request.Method = "GET";
    request.ContentType = "application/x-www-form-urlencoded";
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    return response;
}

The problem is that, I get a timeout on the FOURTH REQUEST. It is really weird and I cannot get the hang of it. The code worked just fine when it was in a single-threaded application. I am also making sure to close the response stream using:

response.Close();

The requestURI is correct, ’cause I tried copying and pasting it into my browser. Actually, it doesn’t matter what the 4th request is (I’ve tried with different ones), I always get a timeout.

I guess it may be something related to thread-limits, but I really don’t know how to solve it. Any suggestions would be greatly appreciated.

Thank you.

  • 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-27T21:08:06+00:00Added an answer on May 27, 2026 at 9:08 pm

    After a lot of blood, sweat and tears, I managed to solve it.

    It was a stupid mistake really, turns out there was this one place where I was not closing the request.

    For some (unknown) reason, this does not affect the requests when made from a Web Application, but, when issuing the requests from a Console Application, timeout problems are encountered.

    Thank you @arx for your help – much appreciated.

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

Sidebar

Related Questions

I have a multi threaded client server application which uses Sockets. When a new
I currently have heavily multi-threaded server application, and I'm shopping around for a good
I have a multi-threaded application with (4) thread i want to know how much
I have a multi-threaded, multi-server web application with hibernate and spring managing transactions with
I have a multi-threaded application written in Python in which one thread takes care
I have a multi-threaded Windows application that occasionally deadlocks. Inevitably this happens on a
I have a multi-threaded application in C# which tries to write to a TextBox
I have a .NET (C#) multi-threaded application and I want to know if a
i have a multi-threaded application which wants to send a sequence of data to
I have a multi-threaded application in a POSIX/Linux environment - I have no control

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.