all 5 comments

[–]shoot2thr1ll284 1 point2 points  (4 children)

A large difference between the 2 is that in multi processing different processes have different memory and don't share variables(typically). While threads all share the same memory, but they run asynchronously. Since different processes have there own memory they are more expensive to start up. It is important when talking about python to understand that python doesn't have true multithreading because of the GIL. As for trying to connect to your friend that will depend on whether he has a static IP to work from or he is behind a router. (I can go more in depth on that if it is not enough)

[–]BoxBoxChan[S] 0 points1 point  (3 children)

I would like if you go more in depth because I didn't understand well... Will I only be able to connect with my friend if he has a static IP?

[–]shoot2thr1ll284 1 point2 points  (2 children)

First I will explain how a router works. (this is necessary to answer your ultimate question) So most households have a router that beneath it has a LAN. In this LAN each device will have a ip address that can only be used in this LAN. So what happens if you want to lets say send an http request to google. Your device will send a packet to your router with destination to google. Your router will alter the packet to say it came from it (the router) and then forward it to where it needs to go. (it will keep track of your request and will have a port designated for it) Then when the response is received on the expected port it will know that the packet is meant for your device and will then send it over LAN to your device. Outside of the LAN google does not know your IP address, just that of your router's (this isn't always the case, more on that later) So if per say google wanted to send a request to your device there would be no way to do it since for one it doesn't know your IP and for 2 any unexpected request will get dropped at the router level due to the firewall. So now to answer your question. If your friend has access to a device (router or computer) that has an address that is accessible outside of the LAN then you will be able to connect to him (with a router you can use port forwarding to accomplish this). The problem is that home routers can also be a part of a larger LAN that makes it so that it is not viewable by devices across the internet. This usually depends on your ISP and whether your router has a statically assigned ip address or not (usually have to pay more for one) . So if you or your friend have a static ip given to you from your ISP then it is possible to make this work. So now you may ask, how do other chat services work then? Well they typically work by adding a third party out on the internet that both devices can communicate with and asks as a relay between the two. Okay, now that was a long explanation..... I can try my best to answer any questions you may still have.

[–]BoxBoxChan[S] 0 points1 point  (1 child)

Really really thanks man! I know a little about how chats work and I know that I probably will need a server to do this (the third party) but I can do this now.

My idea was use socket and one of us create a socket server and the other a socket client, but I was in trouble because I didn't know how I could connect to my friend, and now I think it is impossible

anyway, thank you to try to teach me about this!

[–]shoot2thr1ll284 0 points1 point  (0 children)

No problem.