I start a server using sockets and want to allow clients to coect to it.
self.sock.bind(('0.0.0.0',0)) # 0.0.0.0 will allow all coections and port 0 -> os chooses a open port.
stroke_port=self.sock.getsockname()[1]
self.sock.listen(75)
self.open_port_popup(stroke_port)
Now, for other clients to coect I have port forward it manually and it works fine. 
I want to do this in automated fashion. -> I try upnp.
import miniupnpc
def open_port(port_no):
'''this function opens a port using upnp'''
upnp = miniupnpc.UPnP()
upnp.discoverdelay = 10
upnp.discover()
upnp.selectigd()
# addportmapping(exteal-port, protocol, inteal-host, inteal-port, description, remote-host)
result=upnp.addportmapping(port_no, 'TCP', upnp.lanaddr, port_no, 'testing', '')
retu result
It opens a port shown in the image below. But the port-forwarding list shown in the first image is empty. It doesn't work and clients can't coect. How can I fix this? What am I missing? 
Same question: https://stackoverflow.com/questions/36123075/port-forwarding-in-python-to-allow-socket-coections . Asked because it maybe more relevant here.
برچسب:
نویسنده: استخدام کار