发现 TCP/IP 套接字?
我为此使用 Objective-C 和 Java,但我认为这个问题与语言无关。
我有一个通过 TCP/IP 与 Java 服务器通信的 iOS 客户端。现在我需要至少告诉其中一方另一方的 IP 地址。是否有一种标准方法可以“发现”IP 地址(从一侧或另一侧)?
另外,切换到 UDP 将如何影响答案?
I am using Objective-C and Java for this, but I think the question is language-neutral.
I have an iOS client that talks to a Java server over TCP/IP. Right now I need to tell at least one of the parties the IP address of the other. Is there a standard way that I can "discover" IP addresses (from one side or the other)?
Also, how would switching to UDP affect the answer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有许多协议用于发现网络上的其他设备/服务器。 iOS 领域最常用的之一是“Bonjour”。查看 Apple 的示例应用程序。
There are many protocols for discovering other devices/servers on the network. One of the most commonly used in the iOS realm is "Bonjour". Look at Apple's sample apps.
是的,这就是所谓的“端口嗅探”,并且肯定会给您带来麻烦,因为这是一种常见的攻击。
您只需尝试某个范围内的所有 IP 地址即可。许多防火墙产品会将此视为“入侵”尝试,并使用入侵检测软件记录您的信息。
我们几乎从不“发现”地址。
这就是“域名”的用途。
Yes, it's called "port sniffing" and will certainly get you in trouble since it's a common kind of attack.
You simply try all IP addresses in a range. Many firewall products will consider this an "intrusion" attempt and log you with the intrusion detection software.
We almost never "discover" addresses.
That's what "domain names" are for.
为什么服务器不能有众所周知的 DNS 名称?
Why can't the server have a well known DNS name?