Multiple Object Declarations
I'm finishing up that server I was writing in C# and just noticed a problem. A lot of what I've written has been learned from other source code I've seen, as I've had no previous experience in network programming. One problem I just noticed from something I had seen is this:
The server sets up a socket that acts as a listener. Every time that socket recieves a request it starts a new thread to process that request. Basically I have a while loop that will cycle until the user tells the server to stop accepting requests. In that loop, a thread is declared, which means I'm going to have multiple declarations. This was on example source code from a seemingly reliable source, so I ignored it before now. Can anyone think of a way around this if this is indeed a problem?
while (Status = true)
Thread ClientThread = (new ThreadStart(Client.Http());
edit: The above source code has been oversimplified to illustrate only the problem at hand. The threads are only created after a request has been recieved.