Socket类的常用方法:
public Socket(InetAddress address,int port) throws IOException
public Socket(String host,int port) throws UnknowHostException,IOException
public Socket(InetAddress address,int port,InetAddress localAddr,int localport) throws IOException
public InetAddress getInetAddress()//返回套接字连接的主机地址
public InetAddress getLocalAddress()//返回套接字绑定的本地地址
public InputStream getInputStream()throws IOException//获得该套接字的输入流
public int getLocalPort()//返回套接字绑定的本地端口
public int getPort()//返回套接字连接的远程端口
public OutputStream getOutputSteam()throws IOException//返回该套接字的输出流
public int getSoTimeout()throws SocketException//返回该套接字最长等待时间
public void setSoTimeout(int timeout)throws SocketException//设置该套接字最长等待时间
public void shutdownInput()throws IOException//关闭输入流
public void shutdownOutput()throws IOException//关闭输出流
public void close()throws IOException//关闭套接字
ServerSocket类的常用方法:
public ServerSocket(int port) throws IOException
public ServerSocket(int port,int backlog) throws IOException
public ServerSocket(int port,int backlog,InetAddress bindAddr) throws IOException
public Socket accept() throws IOException//监听并接受客户端Socket连接
public InetAddress getInetAddress()//返回服务器套接字的本地地址
public int getLocalPort()//返回套接字监听的端口
public int getSoTimeout()throws SocketException//返回该套接字最长等待时间
public void setSoTimeout(int timeout)throws SocketException//设置该套接字最长等待时间
public void close()throws IOException//关闭套接字
待续