Click here to Skip to main content
15,848,580 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Using multiple cores within a single thread in C++ and MFC Pin
David Crow22-Nov-16 13:48
David Crow22-Nov-16 13:48 
AnswerRe: Using multiple cores within a single thread in C++ and MFC Pin
leon de boer22-Nov-16 20:15
leon de boer22-Nov-16 20:15 
QuestionRun time validation in .RC file in VC++ Mfc application Pin
rajmohanpatel22-Nov-16 0:50
rajmohanpatel22-Nov-16 0:50 
AnswerRe: Run time validation in .RC file in VC++ Mfc application Pin
Jochen Arndt22-Nov-16 1:11
professionalJochen Arndt22-Nov-16 1:11 
QuestionTCP server handle Clients, std::map or array? Pin
bestbear20-Nov-16 6:03
bestbear20-Nov-16 6:03 
AnswerRe: TCP server handle Clients, std::map or array? Pin
Afzaal Ahmad Zeeshan20-Nov-16 22:36
professionalAfzaal Ahmad Zeeshan20-Nov-16 22:36 
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear20-Nov-16 23:23
bestbear20-Nov-16 23:23 
AnswerRe: TCP server handle Clients, std::map or array? Pin
Jochen Arndt21-Nov-16 1:22
professionalJochen Arndt21-Nov-16 1:22 
Some thoughts about your posts (the initial one and the above reply to Afzaal Ahmad Zeeshan).

Do you really need to store the IP? If so, don't store it as string.

There is no need to generate a (re-usable) connect ID. You already have one:
The connection socket handle.
Using the handle avoids also storing the IP because you can get the IP from the handle using getpeername. But using the handle makes using a map more appropriate.

There is also a solution to avoid locking at all:
Just let the functions be executed in the same thread. As far as I understand there are three events: connection, disconnection, and periodical updates. If connection and disconnection are events issued from other threads, implement signaling functions passing the socket handle.

My suggestion:
Use a map storing the socket handle and avoid locking by putting all associated functions into a single thread.
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear21-Nov-16 2:11
bestbear21-Nov-16 2:11 
GeneralRe: TCP server handle Clients, std::map or array? Pin
Jochen Arndt21-Nov-16 3:35
professionalJochen Arndt21-Nov-16 3:35 
GeneralRe: TCP server handle Clients, std::map or array? Pin
bestbear21-Nov-16 3:48
bestbear21-Nov-16 3:48 
QuestionSimple WaitForSingleObject question Pin
ForNow19-Nov-16 17:14
ForNow19-Nov-16 17:14 
AnswerRe: Simple WaitForSingleObject question Pin
Midi_Mick19-Nov-16 18:09
professionalMidi_Mick19-Nov-16 18:09 
GeneralRe: Simple WaitForSingleObject question Pin
ForNow20-Nov-16 11:48
ForNow20-Nov-16 11:48 
AnswerRe: Simple WaitForSingleObject question Pin
Midi_Mick20-Nov-16 15:17
professionalMidi_Mick20-Nov-16 15:17 
QuestionComponent "Assimp" and Export 3D Scene into Graphical File Pin
Onic77719-Nov-16 12:47
Onic77719-Nov-16 12:47 
AnswerRe: Component "Assimp" and Export 3D Scene into Graphical File Pin
leon de boer19-Nov-16 20:17
leon de boer19-Nov-16 20:17 
Questionpkg_config ?? Pin
Vaclav_18-Nov-16 15:27
Vaclav_18-Nov-16 15:27 
AnswerRe: pkg_config ?? Pin
Richard MacCutchan18-Nov-16 22:55
mveRichard MacCutchan18-Nov-16 22:55 
GeneralRe: pkg_config ?? Pin
Jochen Arndt18-Nov-16 23:54
professionalJochen Arndt18-Nov-16 23:54 
GeneralRe: pkg_config ?? Pin
Richard MacCutchan19-Nov-16 2:21
mveRichard MacCutchan19-Nov-16 2:21 
GeneralRe: pkg_config ?? Pin
Vaclav_19-Nov-16 10:29
Vaclav_19-Nov-16 10:29 
GeneralRe: pkg_config ?? Pin
Richard MacCutchan19-Nov-16 13:03
mveRichard MacCutchan19-Nov-16 13:03 
AnswerRe: pkg_config ?? Pin
markkuk21-Nov-16 0:39
markkuk21-Nov-16 0:39 
GeneralRe: pkg_config ?? Pin
Vaclav_21-Nov-16 5:45
Vaclav_21-Nov-16 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.