通过互联网使用远程应用程序传输数据的最佳方式是什么?
我正在制作一个相对简单的程序,该程序也将在一些朋友的计算机上运行,他们需要共享一些信息。他们将需要交换 ip,以防通过 dhcp 更改它们,也许将来还会发生一些其他事情,但现在就是这样(如果我也更改它,这可能会用于更新程序,我想)。
如果有更好的方法,无需中间人服务器,可以防止他们丢失 IP,这也会有所帮助,但最坏的情况我可以打电话给他们询问,因为这种情况很少发生(如果有的话)。我相信我们的 ISP 每 30 天更新一次,而且他们经常保持相同的状态,所以我怀疑这会成为一个问题,但如果是这样的话,这种情况很少见,那会是一个小小的不便。
我之前没有做过太多的网络编程/脚本编写,所以我不确定从哪里开始处理这个问题。我使用过 urllib/urllib2 和 mechanize,但我猜这些虽然可以工作,但并不是一个优雅的解决方案。我以为电脑只会通过指定的端口进行通信并通过那里监听,但我不知道哪个模块会处理这样的事情。
谢谢朋友们。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果更改 IP 地址是您主要关心的问题,像 dyndns.com 这样的服务肯定会有所帮助。 (您也可以获得自动客户端,当您的 IP 地址更改时,它将更新您的 DNS 条目。)
在数据传输之后,您最好使用现有协议(例如 HTTP、FTP 等)。例如,有大量现有的 HTTP 服务器库。也许基于此的东西会引起兴趣: http://docs.python.org/library/basehttpserver .html
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