Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 WAN networking through python
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shaon




PostPosted: Mon Jun 23, 2008 5:21 pm   Post subject: WAN networking through python

I got my game to work over a LAN however what I don't get is that it doesnt work over a WAN.

the steps i followed are: ( stuff like initializing the sockets have been ommited )

1) get IP using gethostbyname( gethostname() )
2) bind IP with a port that I just typed up (something like "123456")
3) then call "<socket name>.accept()"

the client after asking the user to input IP attempts to connect by calling <socket name>.connect( (IP,port) )
the client can't connect to servers that are over WAN, only LAN.

Is there some special code u input for making the connection possible over WAN?
Sponsor
Sponsor
Sponsor
sponsor
btiffin




PostPosted: Mon Jun 23, 2008 7:25 pm   Post subject: Re: WAN networking through python

There may be a firewall between client and server. Client will need outgoing access to port#. (Server firewall will need to allow incoming on port#).

There may be a proxy server on client end. If so, ask again for more deets.

Is the IP you get from socket.gethostbyname(socket.gethostname()) the same as the IP that shows up on something like wanip.org? (Or ipconfig cmd from Windows or ifconfig on Linux? ifconfig lists it as "inet addr") The local IP address may be different from the cable-modem (or whatever device you hook up with) global IP address that others will need to connect to.

Those are three possibilities.

Cheers
Aziz




PostPosted: Tue Jun 24, 2008 8:17 am   Post subject: RE:WAN networking through python

You'll need to send the data out on a port as well as the address. And you'll need the correct WAN address (wanip.org will do it). If either computer is behind a firewall or router, you'll have to open the port you're using. I think a lot of 5 digit ports (54435 for example) are open by default? At least according to port checkers. You can get a port checker to scan quickly from online, just google.

So if you decide you want to use port 6889, for example, and the receiver's ip is 205.170.32.45, you would send out on address "205.170.32.45:6889" the ':' separates the address and port. At least that's as far as I understand, I may be wrong. I haven't done it in code, but hosting your own web/torrent/samba/print/file/ftp/vnc server helps you understand ports a bit Smile
shaon




PostPosted: Tue Jun 24, 2008 4:14 pm   Post subject: Re: WAN networking through python

I got my networking to work, and in fact I built a whole 8 player RTS over it. I just realized after awhile that when I use the function to get the computers IP, it gives back the LAN IP, which is fine if a person over LAN is trying to connect, however it is different when a person over WAN is trying to connect, since the IP i get back is not WAN IP but LAN IP.
Aziz




PostPosted: Wed Jun 25, 2008 8:45 am   Post subject: RE:WAN networking through python

Ah yes, you'll have to find a way for the client to retrieve his own ip. You could urlopen and just strip the <font> tags on that page to give you the ip, or have some other way of doing so.

Here's an idea: The server has to find it's external ip, which it then gives to players (wether its embedded in the install, whatever, somehow the client game has to know the server ip). Then, the client sends some data to the server. I'm pretty sure the server can determine the sending IP (this would be the WAN ip, as the client's gateway will add the WAN ip to the packet/frame/whatever)
Zeroth




PostPosted: Wed Jun 25, 2008 9:31 am   Post subject: Re: WAN networking through python

I did a quick google check, found this mailing list... and several different solutions.

http://mail.python.org/pipermail/python-list/2003-March/192309.html
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: