Thread closing Socket

G

Guest

I have a server app that has several threads, one for listening, one for
connecting and one for processing messages. The listening thread will listen
untill the app closes, but the connecting thread will try to connect to X
amount of other apps then close down once all the connections are valid. The
problem I'm having is that after I get all my connections in the connecting
thread, the thread closes down, when this happens it automatically closes the
sockets which have connected and gives me "The I/O operation has been aborted
because of either a thread exit or an application request" (ErrorCode 995).
I'm storing the connection once the connect has happened outside of the
thread that is doing the connecting ? IF I leave my thread go on forever then
this doesn't happen but it also means the thread isn't doing anything ? Are
you allowed to pass sockets about between threads without closing the
underlying connection ?
 
W

William Stacey [MVP]

Your connection thread only has refereces to the socket object or a clone?
Guess that maybe if you have a clone or copy, then it is be destructed after
thread closes down and object goes out of scope.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top