Socket py server and client | Sololearn: Learn to code for FREE!


Socket py server and client

When the server and client are connected to the same network, the connection is made, but when the network is different, there is no connection. What should we do?

12/18/2020 9:15:46 AM

mahdi omrani

5 Answers

New Answer


It is a networking relevant problem that requires more setting and configurations in the routers and firewalls in both machines.But in python code you have to indicate the host name and address that server will listen to for the server and what host and and port address will client listen to for client .Setting host to in server side will let it binding to all up address.


Whats your problem? You're not in the network, It makes sense. You need the private ip to make an arp request to give you the mac of the device you want and then the info reaches them. Still have to mess around a bit, but figure out what your public ip is. (There are apps or just search "whats my ip") when you connect from the outside, you need to use the public ip to communicate with your network. You may also need to get into your router and set up port fowarding for whatever port you use when you open a connection.



I used in the IP server and the client also launched the private IP of the server. So you say I should use public IP on the client? And should I enter the settings of my router to connect from outside? And what new law should be created in the firewall to connect a special server-client communication program from the external network


I'd keep it specific so you can narrow down problems. Drop the o.0.0.0 and use the private ip to bind to the server code. Then open up whatever ports you want to use and have them directed to your device, Then from outside the network use the public ip and whatever port you opened to communicate with the device inside