Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Socket and multiple Threads
Re: Socket and multiple Threads [message #27310 is a reply to message #27309] Mon, 12 July 2010 00:48 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14266
Registered: November 2005
Ultimate Member
Sc0rch wrote on Sun, 11 July 2010 17:50

Hello, everyone!

Is there any example for this topic? In my program, when I try to use the Socket in threads, Socket is always closed. One variable: in main thread it's open, in other threads - closed. Why so?

Thank you,
Anton.


Hey, it is still the same story (as with SQL).

As soon as you have multiple threads and shared object, you HAVE TO "serialize" the access to the object using the mutex, so that only single thread "runs" the object at any given time. I mean, only single thread at any given time can read/write/execute members of object. This is what mutexes are for.

Rules are more fine-grained, but in practice this pretty much sums it.

Note: There ARE some objects where this does not hold, where you can call methods without mutex locking. Most of them are associated with multithreading, e.g. Mutex class itself... Smile
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SSL patch
Next Topic: Stop Download
Goto Forum:
  


Current Time: Sat Jul 19 12:18:41 CEST 2025

Total time taken to generate the page: 0.03701 seconds