获取远程计算机看到的本地计算机的DNS名称 [英] Get DNS name of local machine as seen by a remote machine

查看:91
本文介绍了获取远程计算机看到的本地计算机的DNS名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作点对点即时消息应用程序。

I'm making a peer-to-peer instant messaging application.

目前,如果UserA.pool.net对UserB.pool.net说hello ,用户A看到你:你好,用户B看到UserA.pool.net:你好。

Currently, if UserA.pool.net says "hello" to UserB.pool.net, User A sees "You: hello" and User B sees "UserA.pool.net: hello".

而不是用户A看到你,我想要他们查看自己机器的主机名,以便用户A看到与用户B相同的文本。

Rather than User A seeing "You", I want them to see the hostname of their own machine so that User A sees the same text as User B.

推荐答案

简短的回答是如果确实希望用户A和用户B看到相同的文本,则不能依靠自己查找主机名。您需要用户B将用户A主机名的视图传输给用户A,反之亦然。由于NAT,您将无法检查自己计算机的主机名。

The short answer is that if you really want User A and User B to see the same text, you can't rely on finding out your hostname yourself. You need User B to transmit their view of User A's hostname to User A and vice versa. Due to NAT, you won't be able to just check your own computer's hostname.

或者,(Jonathon在问题评论中打败了我)你可以用户发送自己的私有主机名作为连接握手的一部分,并使用它来在远程端打印消息。

Alternatively, (Jonathon beat me to this in the question comments) you can have each user send their own private hostname as part of the connection handshake and use that to print messages on the remote end.

这篇关于获取远程计算机看到的本地计算机的DNS名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆