简体   繁体   中英

Why does Socket.connect uses a SocketAddress rather than a InetSocketAddress?

Why does Socket.connect uses a SocketAddress rather than a InetSocketAddress?
I read the source code of Socket.connect , it just cast a SocketAddress to a InetSocketAddress , and it throws a IllegalArgumentException if the SocketAddress could not cast to a InetSocketAddress .
I am very confused about the significance of this.

基本思想可能是Socket类的将来版本可以支持其他类型的连接。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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