简体   繁体   English

动态IP地址的套接字

[英]Socket for dynamic IP Address

I'm creating a client/server application that should work on LAN. 我正在创建一个应该在LAN上工作的客户端/服务器应用程序。

First with RMI the user register their i dont know what(IP?), this is the question :) 首先用RMI用户注册他们我不知道什么(IP?),这是问题:)

After that i create a ServerSocket and waiting for accept(). 之后我创建一个ServerSocket并等待accept()。

Now the client(or better, the server..that have the registered user) want to establish an connection but... what if the IP Address was changed ? 现在客户端(或者更好的是,具有注册用户的服务器)想要建立连接但是...如果IP地址被更改了怎么办?

There is a way to "register something" on the server that if the IP change all continue to work? 有一种方法可以在服务器上“注册”,如果IP更改全部继续工作?

I try to explain it better: i cant register an IP address and later connect on it, because if the IP change i lost the reference. 我试着更好地解释它:我无法注册一个IP地址,然后连接它,因为如果IP更改我丢失了引用。 I would like to register "something" that is idipendente from the IP. 我想注册来自IP的idipendente的“东西”。

Hope you have understand my question.. 希望你能理解我的问题..

The answer is to use DNS. 答案是使用DNS。 DNS is the appropriate de-referencing mechanism to obtain one or more IP addresses for a given name. DNS是获取给定名称的一个或多个IP地址的适当解引用机制。

You should DNS, which can translate an hostname, to a specific IP address. 您应该将可以将主机名转换为特定IP地址的DNS。 Of course I suggest you to suo exception to verify if the host is alive. 当然我建议你suo exception来验证主机是否还活着。 You have also other solution; 你还有其他解决方案; you can set up a fixed ip in the LAN directly from the server, or from the page control of the router (if you are use the infrastructure in the LAN). 您可以直接从服务器或路由器的页面控件(如果您使用LAN中的基础结构)在LAN中设置固定IP。 If you plane to you it remotely, you will have to use the DDNS, where you can the DNS for a dynamic IP. 如果您远程飞机,则必须使用DDNS,您可以在DNS中使用动态IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM