[Solved] I wrote socket programm which sends message from server to clinent, but doesn’t work over WAN PUBLIC INTERNET

jemala4424 Asks: I wrote socket programm which sends message from server to clinent, but doesn’t work over WAN PUBLIC INTERNET
SO I wrote 2 program::server.py and client.py It works fine on my pc and I think it will also on LAN PRIVATE NETOWRK But I’ve heard that public IP address is assigned for a Wifi router/modem, so how should the program know on which specific device of public ip it should send info to? I asked bit unclear sorry, I’m not a native speaker I’ll ask shortly: how to edit this code for public connection?

Code:
    #server.py:
import socket
import pyautogui
server = socket.socket(socket.AF_,socket.SOCK_STREAM)
server.bind(("192.168.1.56",2101))#private IP adress
        
server.listen(5)


klienti , addr = server.accept()
asdf = pyautogui.prompt("mesiji:")
klienti.send(bytes(asdf,"utf-8"))

#client.py:
import socket
import pyautogui

server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.connect(("192.168.1.56",2101))

mesiji = server.recv(1024)
pyautogui.alert(mesiji.decode("utf-8"))

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.