服务器java 客户端c_局域网象棋 Java-02-S/C模式设计服务器与客户端

public Socket(String host,

int port)

throws UnknownHostException,

IOException

Creates a stream socket and connects it to the specified port number on the named host.

If the specified host is null it is the equivalent of specifying the address as InetAddress.getByName(null). In other words, it is equivalent to specifying an address of the loopback interface.

If the application has specified a server socket factory, that factory’s createSocketImpl method is called to create the actual socket implementation. Otherwise a “plain” socket is created.

If there is a security manager, its checkConnect method is called with the host address and port as its arguments. This could result in a SecurityException.

Parameters:

host - the host name, or null for the loopback address.

port - the port number.

Throws:

UnknownHostException - if the IP address of the host could not be determined.

IOException - if an I/O error occurs when creating the socket.

SecurityException - if a security manager exists and its checkConnect method doesn’t allow the operation.

IllegalArgumentException - if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.

See Also:

setSocketImplFactory(java.net.SocketImplFactory), SocketImpl, SocketImplFactory.createSocketImpl(), SecurityManager.checkConnect(java.lang.String, int)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值