Click to See Complete Forum and Search --> : Multithreaded TCPClient
aspivey
June 11th, 2002, 08:38 AM
I have setup a simple TCPListener and TCPClient that runs in a background thread on a server app. It works fine and connects correctly to clients and fetches messages. I wish to make this multithreaded so that as each client connects a new thread is created rather than having to wait for the single background thread to finish and process the next connection request.
I have tried several ways to do this and always wind up with a vicious loop of thread creation and no processing.
I would greatly appreciate a pointer to an article or snippet that will get me moving in a positive direction again.
Thx for your help
Archie
:confused:
jparsons
June 11th, 2002, 08:45 AM
Originally posted by aspivey
I have setup a simple TCPListener and TCPClient that runs in a background thread on a server app. It works fine and connects correctly to clients and fetches messages. I wish to make this multithreaded so that as each client connects a new thread is created rather than having to wait for the single background thread to finish and process the next connection request.
I have tried several ways to do this and always wind up with a vicious loop of thread creation and no processing.
I would greatly appreciate a pointer to an article or snippet that will get me moving in a positive direction again.
Thx for your help
Archie
:confused:
I believe that I've already responded to this post in another forum and recommended that you use Asynchronus I/O for it but I found a decent set of power point slides on multithreading in the .NET environment so here's the link. http://www.renaissance.co.il/ivbug/meeting46/VBMultithreading.ppt
aspivey
June 11th, 2002, 08:56 AM
Thanks Jared,
Yes, you did respond and I digested your posting content. I did a quick and dirty with the sockets client and it seems to be blocking. I'm running a client connect on another box and when it connects to the server socket, it will not connect for another exchange until the previous one has cleared.
I need to be able to instantiate a new thread for each connection whether it be a tcpclient connection or a socket connection. The app that I'm having to build will not have a callback. The clients are a moving target as they connect and disconnect quickly. They identify themselves with a unique ID string. I do some work for the client that is identified in the message also. The unique ID is used later to send the result of the work event back to them. The client is using a radio interface that connects via a TCP port. The client MUST connect/disconnect fast.
Thanks for your help Jared,
Archie
:)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.