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!
4/29/2022 4:14:34 AMKetan Lalcheta
6 AnswersNew Answer
True In that case youlll need to fork a new process https://www.delftstack.com/howto/cpp/cpp-fork/
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.
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
Spoke too soon : Heres an example of threading working https://code.sololearn.com/c3WW9t9hv4xB/?ref=app
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
Unfortunately I can't use fork as I am not on Linux... Any counterpart for windows ?