C# API for networking.

  • Thread starter Thread starter Ramkrishna Kulkarni
  • Start date Start date
R

Ramkrishna Kulkarni

Hi,
I am writing a multithreaded application. Each thread creates an
object of WebClient class of C# to open a new connection to the server
everytime.
However, the API seems to be optimizing this and hence it is opening
only two TCP connections to the server for the complete set of
threads. To simulate some real life scenario, I need to open separate
connection for each thread.

Can you please suggest how one can tell the API to open a new
connection everytime? Are there any other API's in C# for networking?

Regards,
Ram
PS:I want to avoid sockets :)
 
Ramkrishna Kulkarni said:
Hi,
I am writing a multithreaded application. Each thread creates an
object of WebClient class of C# to open a new connection to the server
everytime.
However, the API seems to be optimizing this and hence it is opening
only two TCP connections to the server for the complete set of
threads. To simulate some real life scenario, I need to open separate
connection for each thread.

Can you please suggest how one can tell the API to open a new
connection everytime? Are there any other API's in C# for networking?

http://msdn.microsoft.com/library/d...ml/gngrfaddelementforconnectionmanagement.asp

In your configuration there's a setting that controls this. It's set by
default in machine.config to allow only 2 connections to each web server
(just like IE).

You can change it there, or set it in your app.config.


<system.net>
<connectionManagement>
<add address="*" maxconnection="2"/>
</connectionManagement>
</system.net>

David
 
In your configuration there's a setting that controls this. It's set by
default in machine.config to allow only 2 connections to each web server
(just like IE).

You can change it there, or set it in your app.config.


<system.net>
<connectionManagement>
<add address="*" maxconnection="2"/>
</connectionManagement>
</system.net>

David

Hi David,
Thank you very much. Increasing maxconnection value in machine.config
file solved my problem.
Regards,
Ram
 
Hi,
After modifying the machine.config file, my application is opening
more than two connections. However it is now getting restricted to
number of threads in the application. Only one connection per thread
(I am creating 3 objects of WebClient class per thread).
I searched *.config files for something like <maxconnections per
thread>. However din't find anything which specifies number of
connection per thread.
Is there anything like this in the config files or any method in C#
which allows us to specify HTTP connection per thread?

Regards,
Ram
 
Hi,
This is a reminder to my earlier question.
If anybody knows of any .Net config files or other methods by which we
can specify how many connections to establish between two machines,PER
THREAD, please let me know.
Regards,
Ram
 
Back
Top