EDN Admin
Well-known member
HI guys,
I am trying to understand what happens when i use the BeginAccept Method of the socket class.
When you use BeginAccept what is actually happens? Does the system uses the ThreadPool threads to process the acceptance of a new connection, and then sends a message to the executing thread with an IAsyncResult? or that the ThreadPool thread is the one that executes the AcceptCallback method?
I am trying to make an Asynchronus MultiThreaded Server Application. I have 25 threads that are background threads, and I want to use them to provoke the client connections and process data recived. But i dont understand how to marry MultiThreading with Asynchronus sockets.
When i call BeginSomething, when the code goes to the CallBack method, does it Kill the thread that was created seperately? or does the system just signal the executing thread with the IAsyncResult and that is it and the main application thread is what is going the data processing?
If this is the case, does that mean i have to somehow instruct the 25 threads in my application to execute the BeginRecive in a loop? my server handles many connections and each socket is added to a Queue.
Where do i use the 25 threads to improve speed and scalability? Or do i not need to create 25 threads, and asynchronus operations of the socket would mean that i am implicitly using multi-threading by default, and that when i call BeginSomething the system thread will execute the CallBack method?
Also do I need to call BeginRecieve in a loop? or once i call BeginRecive in a socket, it means that there is a thread that is polling for client data and will never get stopped unless i stop the server process? or does it end once i go to the callback method and call EndRecieve? which means that you have to recall BeginRecieve in a loop?
Anyhelp would be appreciated!
View the full article
I am trying to understand what happens when i use the BeginAccept Method of the socket class.
When you use BeginAccept what is actually happens? Does the system uses the ThreadPool threads to process the acceptance of a new connection, and then sends a message to the executing thread with an IAsyncResult? or that the ThreadPool thread is the one that executes the AcceptCallback method?
I am trying to make an Asynchronus MultiThreaded Server Application. I have 25 threads that are background threads, and I want to use them to provoke the client connections and process data recived. But i dont understand how to marry MultiThreading with Asynchronus sockets.
When i call BeginSomething, when the code goes to the CallBack method, does it Kill the thread that was created seperately? or does the system just signal the executing thread with the IAsyncResult and that is it and the main application thread is what is going the data processing?
If this is the case, does that mean i have to somehow instruct the 25 threads in my application to execute the BeginRecive in a loop? my server handles many connections and each socket is added to a Queue.
Where do i use the 25 threads to improve speed and scalability? Or do i not need to create 25 threads, and asynchronus operations of the socket would mean that i am implicitly using multi-threading by default, and that when i call BeginSomething the system thread will execute the CallBack method?
Also do I need to call BeginRecieve in a loop? or once i call BeginRecive in a socket, it means that there is a thread that is polling for client data and will never get stopped unless i stop the server process? or does it end once i go to the callback method and call EndRecieve? which means that you have to recall BeginRecieve in a loop?
Anyhelp would be appreciated!
View the full article