那就只修改客户端的ip 把主ip换成服务器允许的ip

解决方案 »

  1.   

    Socket类有这么个构造方法。不知道是不是通过localAddr参数指定本地的IP地址,你自己去测试一下。如果搞定就请客~~public Socket(InetAddress address, int port, InetAddress localAddr,
      int localPort)
      

  2.   

    /**
         * Creates a socket and connects it to the specified remote address on
         * the specified remote port. The Socket will also bind() to the local
         * address and port supplied.
         * <p>
         * If there is a security manager, its
         * <code>checkConnect</code> method is called
         * with the host address and <code>port</code> 
         * as its arguments. This could result in a SecurityException.
         * 
         * @param address the remote address
         * @param port the remote port
         * @param localAddr the local address the socket is bound to
         * @param localPort the local port the socket is bound to
         * @exception  IOException  if an I/O error occurs when creating the socket.
         * @exception  SecurityException  if a security manager exists and its  
         *             <code>checkConnect</code> method doesn't allow the operation.
         * @see        SecurityManager#checkConnect
         * @since   JDK1.1
         */
        public Socket(InetAddress address, int port, InetAddress localAddr,
      int localPort) throws IOException {
    this(address != null ? new InetSocketAddress(address, port) : null,
         new InetSocketAddress(localAddr, localPort), true);
        }