How does Socket/s being taken care of in the memory?  
Author Message
__ButterFly__





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

Hello again :)

I'm just curious, if I have a server, using async-sockets model, and 1000 clients connected, how is it handled

I mean, I'm sure there are no 1000 threads (haha) taking care of each socket instance..

So, what Are there, let's say, 100 sockets taken care of in 1 thread, or what Where can I learn about it What happens if I use Thread.Sleep() in one of the sockets' events (the rest of the sockets are affected )




.NET Development6  
 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

If you are already using Asynchrnous pattern then you 0-1 Thread only, You can make it equal to 0 using BeginAccept or create a Thread and listen Incoming conneciton Requests in it using listener.AcceptTcpClient() or AcceptSocket();

You dont need Threads to Send or Receive Data, Just use Asynchronous Methods on Socket, BeginReceive EndReceive or on NetworkStream, BeginRead, End Read, All clients can be well serviced without needng Threding at all and it'll be manged by OS itself.

Have you started some work If so, Show your code and ask for what prblem you are facing!

Best Regards,



 
 
__ButterFly__





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

Really Well, I already have a well-built server and it's code is way too long to show it in here  Was just wondering, don't really have any problem (:

And it's async pattern, using 0 threads (custom ones that I made).

Anyway what you're saying simply doesn't sound reasonable - 1000 clients are connected, all on the same thread (which is managed by Windows)



 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

Anyway what you're saying simply doesn't sound reasonable - 1000 clients are connected, all on the same thread (which is managed by Windows)

MSDN says this:

"Asynchronous sockets use multiple threads from the system thread pool to process network connections."

Read it youself completely:

ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxnetwork/html/fd85bc88-e06c-467d-a30d-9fd7cffcfca1.htm

Index Search: Asynchronous Client Sockets

Best Regards,



 
 
__ButterFly__





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top



 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

I send you Link to MSDN any how see this on MSDN online:

http://windowssdk.msdn.microsoft.com/en-us/library/bbx2eya8.aspx

And please always mark answered posts as answered

Best Regards!

Rizwan



 
 
Mike Flasko





PostPosted: .NET Framework Networking and Communication, How does Socket/s being taken care of in the memory? Top

This depends on the I/O mechanism being used. For overlapped IO with completion ports, there is typically 1 thread per CPU + a few additional workers. There is a good description of this in Anthony Jones' book on Windows Network Programming