943,874 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 1256
  • Python RSS
Feb 10th, 2009
0

python server port forwarding problem

Expand Post »
am i correct in assuming that when a computer behind a router with port forwarding opens a port (port 1337, when i run my server), that the router automatically notices and sets itself up to send all port 1337 traffic to that computer?

i've got two simple applications, a client and a server. Bound to 127.0.0.1, the client finds the server just fine, but bind the server to the local network address (172.16.0.2) and aim the outgoing connection at the router (public) ip (from whatismyip.com), and the router denies the connection.
i suspect i just need to somehow tell the router that my computer is using port 1337, and that it should forward incoming traffic instead of denying it... or of course i could be hopelessly wrong. anyone, ideas?

#server
import socket
myip = socket.gethostbyname(socket.gethostname())
port = 1337
sock = socket.socket()
sock.bind((myip, port))
sock.listen(5)
print sock.accept()[1]

and

#client
import socket
server = "71.62.9.147"
port = 5132
sock = socket.socket()
sock.connect((server, port))
print "connected"
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Alien15x is offline Offline
1 posts
since Feb 2009
Feb 10th, 2009
0

Re: python server port forwarding problem

1) check firewall in your computer. this is not likely the case. but if you have a firewall set you have to open the port from your firewall too.
2) your router might not working correctly. That actualy happened to me. some routers have the port forwarding in their menu but it does not work. (if you are in the US. that is probably not the case.)
3) restart your router (don't ask )

if I were you I would try to forward some other port that you are sure , some app is listening to. for example I got ssh daemon listening to port 23 so I would try to forward port 23 and try connect to my computer with an ssh client. If I can connect to it , that means my network is fine.

I can not tell you what is wrong with your network but, those are the ways that I would follow to diagnose it. I hope that helps.
Reputation Points: 31
Solved Threads: 5
Light Poster
yilmazhuseyin is offline Offline
48 posts
since Oct 2006
Feb 11th, 2009
0

Re: python server port forwarding problem

You may find your router has a 'virtual server' set up of some kind, if it has then it will allow you to add incoming requests to the list. This will give you the option to have you router watch the information coming on a sepecfic port then forward that request to the internal IP address and port you specify on any computer.

This is how I had my Python server set up, and it worked perfectly. Just remeber accessing the server internally and externally IS different, so test it from an external location.

Chris
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: coulc someone explain vectors?
Next Thread in Python Forum Timeline: XLWT: IO Error[Errno 22]





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC