0

How to create two process

Hi Refer code I prepared for kind of chat messages https://code.sololearn.com/cxenKN8NI1x6 I need to create two different process for player 1 and player 2. Can anyone please guide me on this? I am very new to processes. Thanks in advance!

29th Apr 2022, 4:14 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
6 Antworten
+ 2
True In that case youlll need to fork a new process https://www.delftstack.com/howto/cpp/cpp-fork/
29th Apr 2022, 6:40 AM
Raul Ramirez
Raul Ramirez - avatar
+ 1
FYI When you fork a new procees variables changed in one dont change the variables in the other. They are two seprate processes after the fork. As if you ran the program on two terminals. On the other hand threading stays in one process. And you have to keep in mind what variables each thread is manipulating.
29th Apr 2022, 6:52 AM
Raul Ramirez
Raul Ramirez - avatar
+ 1
Im not sure but this video might help https://youtu.be/W2Qu4RDk__k And for your game id recommend doing socket programming with python https://youtu.be/3QiPPX-KeSc Example as to why 41:20-45:45 Keep in mind he is hardcooding the client messages But you can have each client type in something before sending it
29th Apr 2022, 6:21 PM
Raul Ramirez
Raul Ramirez - avatar
0
Spoke too soon : Heres an example of threading working https://code.sololearn.com/c3WW9t9hv4xB/?ref=app
29th Apr 2022, 6:26 AM
Raul Ramirez
Raul Ramirez - avatar
0
Not sure but I don't think so... Different threads does not mean different process... Right ? Is my understanding correct ? Something to start new process is I never used.. Sometime , although less, but I do have used threads
29th Apr 2022, 6:36 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Unfortunately I can't use fork as I am not on Linux... Any counterpart for windows ?
29th Apr 2022, 4:21 PM
Ketan Lalcheta
Ketan Lalcheta - avatar