简体   繁体   English

Java InetSocketAddress 看起来像 .toString() 吗?

[英]What does Java InetSocketAddress look like .toString()?

I'm doing a .toString() on an InetSocketAddress.我正在 InetSocketAddress 上执行 .toString()。 This is part of an Android websocket client that so far is failing to connect to the host.这是迄今为止无法连接到主机的 Android websocket 客户端的一部分。

Right now the output from a variable address.toString() looks like domain.com/72.xx.xxx.xx:8000 but from what I understand there needs to be two values (IP and port) only?现在变量 address.toString() 的输出看起来像domain.com/72.xx.xxx.xx:8000但据我所知只需要两个值(IP 和端口)?

Thanks letting me know if this looks correct.感谢让我知道这看起来是否正确。

The toString() of InetSocketAddress first calls the toString() of InetAddress and then appends the port number to it and the string returned from toString() of InetAddress is of the form: hostname / literal IP address . InetSocketAddress 的 toString() 首先调用 InetAddress 的 toString(),然后将端口号附加到其上,从 InetAddress 的 toString() 返回的字符串的形式为:主机名/文字 IP 地址

Later port number is concatenated before returning from the InetSocketAddress's toString() to the returned value (from the toString() of InetAddress), hence the final result is hostname / literal IP address:port number .稍后的端口号在从 InetSocketAddress 的 toString() 返回到返回值(从 InetAddress 的 toString() )之前连接,因此最终结果是主机名/文字 IP 地址:端口号

For more information see the JavaDocs for InetSocketAddress's toString() .有关更多信息,请参阅InetSocketAddress 的 toString()的 JavaDocs。

Was able to find an example: http://discuss.itacumens.com/index.php?topic=46099.0能够找到一个例子: http : //discuss.itacumens.com/index.php?topic=46099.0

Basically it is correct :)基本上它是正确的:)

I'll need to debug elsewhere...我需要在其他地方调试...

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

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