设置服务器
我在编程方面真正的弱点之一是网络,所以我承认我对这个项目可能有点不知所措。如果我想做的事情没有任何意义,请随时告诉我
我想做的基本上是在我的笔记本电脑上运行一个程序(可能是 Node.JS)来处理来自网站的请求,执行一些功能,并将数据返回给在网站上运行的客户端。 (研究告诉我这称为 RPC 服务器)
当您在 Node.JS 中侦听请求时,您可以指定一个端口和一个可选的 IP 地址 - 本地主机 127.0.0.1,这是我读过的所有教程都使用的,但是这对于我想要做的事情来说还不够,
我读过我需要设置一个静态 IP 地址?但我认为这些是相对于我的 LAN 的,所以它们就像 192.168.0.X。那么我应该为服务器和客户端指定什么IP呢? (我不认为端口特别重要)。我需要 DNS 吗?
我希望这是有道理的,抱歉有这么多问题,谢谢您的帮助
One of my real weak points in programming is networking, so I admit that I may be a little over my head with this project. Please feel free to tell me if what I'm trying to do doesn't make any sense
What I am trying to do, basically, is run a program on my laptop (Node.JS, probably) that handles requests from a website, does some functions, and serves data back to a client running on the website. (Research tells me this is called an RPC server)
When you listen for requests in Node.JS, you specify a port and optionally an IP Address- localhost, 127.0.0.1, is what all the tutorials I've read have used, but that's not sufficient for what I'm trying to do
I've read that I'll need to set up a static IP Address? But I think those are relative to my LAN, so they'll be like 192.168.0.X. So then what would I specify for the IP for the server and the client? (I don't think the port particularly matters). Do I need a DNS?
I hope this makes sense, sorry for so many questions, thank you for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在本地计算机上运行服务器,并为脚本指定本地 IP 地址,例如 192.168.0.x。但要使该服务器收到连接,您的客户端必须连接到您的外部 IP 地址。这是您连接到 Internet 时从 Internet 提供商处获得的 IP 地址。如果您的外部 IP 是静态的,即它不会改变,那么您可以在客户端脚本中使用它。如果外部 IP 发生变化,您必须设置一条 DNS 记录来解析您的计算机名称。 DynDNS 可用于此目的。
如果您有路由器,则必须对其进行设置,以便将连接转发到运行服务器的笔记本电脑。并且您的防火墙必须配置为允许连接。
You can run a server on your local machine, and you will specify your local IP address for the script, like 192.168.0.x. But for this server to ever receive a connection, your client must connect to your external IP address. It is the IP address that you get from your Internet provider when you connect to Internet. If your external IP is static, i.e. it does not change, then you can use it in your client script. If the external IP changes, you must setup a DNS record that would resolve the name of your computer. DynDNS can be used for that purpose.
If you have a router, it must be setup so that it forwards connections to your laptop where the server runs. And your firewall must be configured to allow connections.