|
All you gotta do is have an IF statement check the number of clients. Now would I recommend hardcoding 25.... nope. Read the restriction quantity from a config file. That way you can change the number of supported clients without recompiling the code. Your app would read in the parameter at startup and pass it to the listen class. The you would have something like:
class listen<br />
{<br />
.<br />
.<br />
.<br />
<br />
uint mClientCount = 0;<br />
uint mClientLimit = 0;
.<br />
.<br />
.<br />
<br />
public listen(uint limit)<br />
{<br />
mClientLimit = limit;
}<br />
<br />
public void startListen()<br />
{<br />
.<br />
.<br />
.<br />
if (mClientCount < mClientLimit)<br />
{<br />
cl= new client(server.AcceptTcpClient());<br />
tcpthread=new Thread(new ThreadStart(cl.getClient));<br />
tcpthread.Start();<br />
++mClientCount; <br />
}<br />
.<br />
.<br />
.<br />
<br />
}<br />
Note: make sure you decrement mClientCount in your Disconnect logic so that you counter stays accurate. Since you are using threads, you will have to manage the synchronized access to the
client counter. You can use lock {} or use a Mutex, or AutoResetEvent depending on your preference and performance needs.
Good luck!
Mike
|
|
|
|
|
is it possible for string type constants to be declared in interfaces in C#.net?how to implement interfaces use these constants in other classes
Sridevi
-- modified at 1:29 Friday 2nd December, 2005
|
|
|
|
|
|
Hi goodmorning,
yaa it doesn't work in interfaces
Sridevi
|
|
|
|
|
|
I wrote this in interface
public interface Style
{
static const string STYLEFREEFORM = "STYLE_FREEFORM";
Error:Interfaces can't contain fields
so how to define constants?,i want to implement these are other classes..any suggestions..give me small example for this context
Sridevi
|
|
|
|
|
Why don't you use a namespace as the logical container for the interface and any constants you want to declare?
Regards,
Rob Philpott.
|
|
|
|
|
Plz give me example
Sridevi
|
|
|
|
|
|
leppie wrote: Also you cannot use the static keyword with const.
I noticed that the other day and don't understand why. Do you know?
Thanks,
Alvaro
I cannot take anything the Bush administration does seriously. The corruption, the cynical disregard for humanity, the cronyism and incompetence, all wrapped in a slimey flag of ultra-marketed nationalism repulses me. -- consdubya from fark.com.
|
|
|
|
|
Alvaro Mendez wrote: leppie wrote:
Also you cannot use the static keyword with const.
I noticed that the other day and don't understand why. Do you know?
IIRC Clarity. All consts are treated statically, and if there were consts and static consts there would be people confused about the difference (none) between them.
|
|
|
|
|
isn't that methods rather than members? Without checking the books I wouldn't have thought you could have any members in an interface. I presume we consider members and fields are the same thing in this context..
Regards,
Rob Philpott.
|
|
|
|
|
Hi Goodmorning,
yaaa in this context members & fields are same..
Sridevi
|
|
|
|
|
...hey guys ..
I m working on the search engine project.....
I urgently need any algorithm to index my database...
I can't store it using STL hash table....anyone knows ..plz tell me....
Aditya Kumar Agrawal
B. Tech. Final Year
MNNIT Allahabad
India-211004
|
|
|
|
|
First, make sure you're in the right forum (C# programming language).
There are lots of articles on the web as well as several open source search libraries that might help you out if you study them. One that comes to mind is Lucene (and the .NET port, DotLucene).
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
..Thanks for this great guidence ... really i didn't have any info regarding DotLucene ... and as i m coding my engine in C# .. so I prefer to put this question in this forum ......
once again thanks a lot
Aditya Kumar Agrawal
B. Tech. Final Year
MNNIT Allahabad
India-211004
|
|
|
|
|
Hi!
I am developing a software using c# for windows platform, and i need to know if there is any possibility of knowing when a system or user process is invoked that is before it's execution.
I will be very grateful for any help.
take care
SAM
SAM
|
|
|
|
|
Well you have a couple options depending on how much control you have over the system and/or user processes. For example, if these processes are also your own source code, then you can design some sort of Health protocol used by all the processes and the Master Service/Process. This would actually pretty fun and easy to do depending on your expertise.
Conversely if you are talking about genuine 3rd party processes, this includes Windows processes then I am afraid we have a complety different cat to skin. You know when you press CTRL+ALT+DEL to bring up the Task List, well get ready cause that is basically what you have to build (aside from the interface). If that is the case, I would have to say that doing so in C# for the sake of using C# would be kinda silly and not advised with all of the marshalling and workarounds to access system data structures`. But under Win32 and VC++ you are in the right element at least. Get the drift?
Finally unless you happen to have lying around, one computer interface to the human brain, it may be slighlty difficult to tell the future. But if your scenario matches the first option then you can ensure the first thing the processes do is use the Health protcol. If you are left with the second option remember the process that scans the Active Task List is probably a high priority process so if your application is polling this list you need to decide how often to interrogate it versus becoming intrusive to the system performance.
Mike
|
|
|
|
|
I have a project that I am working on that requires me to dynamically create the connection string to a SQL Server database. All of our SQL Servers are published within Active Directory. Within SQL Server there is a tab that allows you to add the instance of SQL to Active Directory. This can also be done for a database after SQL has been added to AD (the options tab at the bottom within SQL 2000).
With the database and the SQL instance published in AD I should be able to query AD to find the location of the database, i.e., What server is database X on?, I have looked through System.DirectoryServices and have been able to find how to do this. Any help/leads is greatly appreciated.
|
|
|
|
|
Hi again!
Well i got just the smallest of problems right now. I'm creating a sprite engine in C# and have ran into a problem when creating layers to my screen. The idea was to have a terrian layer, Object layer, and Control layer. Object layer being anything directly related to the game world and Controls being the GUI. The purpose of layers is so if only the controls changed i would only compute the change of the controls and just redraw what i had drawn previous with the past layers. Creating something of "Dirty Sprite" theory- ("Only redrawn what has changed - changed = dirty")
But the problem is before i was using these layers my program wiped the previous layer by filling it with white. I dont believe this will work anymore.
Is there a way to wipe a layer "clear"? So if i draw the layers on top of each other you'll be able to see the layers drawn first through the holes in the top most layers?
Thanks for your help in Advanced!
-- modified at 20:43 Thursday 1st December, 2005
|
|
|
|
|
I am having a lot of issues with this in VS2003 - programming in C#
I am trying to update one field in an XML file using a dataset
The code for the updating is
_______________________________________________________________
<br />
DataRow selectedRow = contacts.Tables[0].Rows[contactlist.SelectedIndex];<br />
selectedRow.BeginEdit();<br />
selectedRow["Service_Release_SQL"] =sr_sql.Text;<br />
selectedRow.EndEdit();<br />
contacts.WriteXml(@"contacts.xml");
______________________________________________________________
where "contactlist.SelectedIndex" gives me the XML row to update, and the field in that row is called "Service_Release_SQL"
This complies OK, and runs without throwing an exception but the result always is that my XML file loses all field after the "Service_Release_SQL"
field.
Can anyone indicate where I am going wrong
Thank you for your time
|
|
|
|
|
Should consult MSDN for this one, copied from there. You may be missing parts of this.
private void WriteXmlToFile(DataSet thisDataSet) {
// Create a file name to write to.
string filename = "myXmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}
|
|
|
|
|
Thanks
I suspect that my trouble is that the dataset is "set" to a different XML schema that the file being loaded (a previous version of the XML file), hence ignoring the columns after the ones it "knows about".
I suspect I will need to specifically load the schema, and save the schema as well as the data.
Will try it out on Monday when I get back to the office
|
|
|
|
|
I want to know how to control windows audio with C#
|
|
|
|
|
When your question is that broad, your best bet is google.
Christian Graus - Microsoft MVP - C++
|
|
|
|