Socket py server and client | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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?

18th Dec 2020, 9:15 AM
mahdi omrani
mahdi omrani - avatar
5 Answers
+ 1
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 0.0.0.0 in server side will let it binding to all up address.
18th Dec 2020, 9:51 AM
HBhZ_C
HBhZ_C - avatar
+ 1
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.
18th Dec 2020, 10:01 AM
Slick
Slick - avatar
0
I used 0.0.0.0 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
18th Dec 2020, 10:24 AM
mahdi omrani
mahdi omrani - avatar
0
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
18th Dec 2020, 10:30 AM
Slick
Slick - avatar