0

I am creating client - server application, where clients are participating in a game. They are communicating with each other by serializing their data and sending it to the server. Later, server forwards that data to the right client. The game requires exactly three players to be played.

To test my app on a local machine, I am starting one instance of server and three instances of client. What I have problem with is that after I set breakpoints in code I am only catching the last instance of client that was run. Can you tell me how can I switch between processes, or choose which specific process I want to debug?

niksrb
  • 459
  • 7
  • 25

1 Answers1

3

You can use the "Attach to Process" option in the Debug menu to choose a specific process for debugging.

  • Pro Tip: Use the keyboard shortcut `Ctrl + Alt + P` to open that menu directly – MindSwipe Apr 11 '19 at 07:50
  • Yes, I have found similar solutions on the internet, but didn't quite understand the way how this works. After I choose the one I want and click "Attach to Process" dialog box appears. What should I select from a list of Available Processes? The one which I want to debug is grayed out here on this list. Can you give me some tips or explain me the steps please? – niksrb Apr 11 '19 at 07:54
  • You need to know process id, [show it](https://stackoverflow.com/q/3003975/1997232) somewhere in client and then it's easy. – Sinatr Apr 11 '19 at 07:57
  • Yea, I know the process ID as it is shown in Processes window. But once again, I don't know what to do with it – niksrb Apr 11 '19 at 07:58
  • Check [msdn](https://learn.microsoft.com/en-us/visualstudio/debugger/attach-to-running-processes-with-the-visual-studio-debugger). You have to identify process by name (to see your clients) and by id (to identify which client out of 3 you want to debug). Once you identify - select it, click attach and enjoy debugging. – Sinatr Apr 11 '19 at 08:01
  • @mjwills Oh, actually that could be the explanation then! Because all processes are grayed out, which may mean that they are attached by default and I have to detach from each one until I stay attached to the one I want, right? – niksrb Apr 11 '19 at 09:00
  • 1
    @niksrb You can attach to more than one process at once. If you are attached to things you aren't expected to, then detach. Or reboot if that doesn't work. – mjwills Apr 11 '19 at 09:28