Local variables in Asynchronous socket server

G

Guest

Hi,

I am implemeting an asynchronous socket server in my app. There will be up
to 30 clients sending data to the socket server.

Within the socket server I will have a number of local variables for each
client connection.

e.g varA, varB, varC, varD.

I have been testing the comms with one client and this has been working fine.

However I now want to test with multiple clients.

For a five client scenarion I want to avoid having to declare each varable 5
times.

e.g varA1, varA2, varA3, varA4, varA5 etc.

Is there anyway(particular place in the code) for me to declare VarA so that
each connection has it's own copy of these variables.

I am using the Asynchronous socket server example in MSDN as a base

http://msdn2.microsoft.com/en-us/library/fx6588te.aspx

Thanks In Advance
Macca
 
J

Jon Skeet [C# MVP]

Macca said:
I am implemeting an asynchronous socket server in my app. There will be up
to 30 clients sending data to the socket server.

Within the socket server I will have a number of local variables for each
client connection.

e.g varA, varB, varC, varD.

That sounds like you should encapsulate those variables within a class.
That way you can have multiple instances of the class to handle
multiple connections.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top