Get DNS name of local machine as seen by a remote machine

前端 未结 4 1907
故里飘歌
故里飘歌 2020-12-15 17:59

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

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

4条回答
  •  不思量自难忘°
    2020-12-15 18:21

    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.

    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.

提交回复
热议问题