views:

63

answers:

1

I'm making a relatively simple program which will also be running on a few friends computers and they need to share some information. They will need to exchange ips in case they are changed via dhcp and maybe a few other things in the future, but right now that's it (this will likely be used to update the program if I ever change it too I figure).

If there's a better way, without having a middleman server, to keep them from losing the ip that would be helpful too, but worst case I can just call them up and ask since this would so rarely happen, if ever. Our isps renew every 30 days I believe, and they often keep the same one anyways, so I doubt that'll ever be an issue, but if so it's so rare it'd be a minor inconvenience.

I haven't done much network programming/scripting before so I'm not sure where to approach this from. I've used urllib/urllib2, and mechanize, but I'm guessing those, while they could work, are not an elegant solution. I was thinking the pcs would just communicate via a specified port and just listen through there, but I don't know what module would handle such a thing.

Thanks friends.

+2  A: 

If change of IP address is your main concern, a service like dyndns.com would certainly be helpful. (You can get automatic clients as well, which will update your DNS entry when your IP address changes.)

After this for data transfer, you're probably better off using existing protocols (e.g. HTTP, FTP, ...). There's plenty of existing HTTP server libraries out there for example. Perhaps something based on this would be of interest: http://docs.python.org/library/basehttpserver.html

Bruno
I thought about that too as I have (very little) experience using that module, but I figured there might be an even leaner way to do it. That could certainly work though if nothing better is suggested.
kryptobs2000
I'll second this, HTTP is by far the easiest way to transfer files over the network. Python's builtin HTTP client libraries are sort of awful, though - consider using httplib2 if they start getting on your nerves ;)
p-static
Ok, well after 2 suggestions towards this I think this is the approach I will take, and thanks for the recommendation towards httplib2 static, hadn't heard of that before.
kryptobs2000