黑马程序员技术交流社区

标题: 关于socket构造函数 [打印本页]

作者: endian11    时间: 2014-6-28 07:04
标题: 关于socket构造函数
为什么socket构造函数:

Socket(InetAddress address, int port)
Creates a stream socket and connects it to the specified port number at the specified IP address.

为什么address可以直接写成字符串(192.168.1.100),而address应该是InetAddress类型才对啊
作者: 陈鹏83    时间: 2014-6-28 08:06
关注,我也想知道
作者: 陈鹏83    时间: 2014-6-28 08:08
InetAddress类是IP地址封装类,同时它也是一个比较奇怪的类——没有公共的构造方法,程序员只能利用该类的一些静态方法来获取对象实例,然后再通过这些对象实例来对IP地址或主机名进行处理。

我准备去查查 api了




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2