Package java.net

Examples of java.net.InetAddress


    }



    public static void testIPv6WithExternalization() throws IOException, ClassNotFoundException {
        InetAddress tmp=Util.getNonLoopbackAddress();
        IpAddress ip=new IpAddress(tmp, 5555);

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        ObjectOutputStream    oos=new ObjectOutputStream(bos);
        byte[]                buf=null;
View Full Code Here





    public static void testIPv6WithStreamable() throws IOException, ClassNotFoundException {
        InetAddress tmp=Util.getNonLoopbackAddress();
        IpAddress ip=new IpAddress(tmp, 5555);

        ByteArrayOutputStream bos=new ByteArrayOutputStream();
        DataOutputStream      dos=new DataOutputStream(bos);
        byte[]                buf=null;
View Full Code Here

    if (b != 333) {
      throw new RuntimeException("default property value set when it should not have been") ;
    }
   
    // get the value which should not have been assigned a default
    InetAddress c = ((DEFAULTS)protocol).getC() ;
    System.out.println("value of c = " + c) ;
        assert c != null;
  }
View Full Code Here

  public ReliableSSLTcpClient() {
    super();
  }

  protected Socket createSocket(String hostname, int port) throws Exception {
    InetAddress outLocalAddr = null;
    String outLocalAddrStr = params.outLocalAddress;
    if (outLocalAddrStr != null)
      outLocalAddr = InetAddress.getByName(outLocalAddrStr);

    int outLocalPort = params.outLocalPort;
View Full Code Here

                            pingable_mbrs + ", local_addr=" + local_addr);
                return;
            }

            // 1. execute ping command
            InetAddress host=ping_dest instanceof IpAddress? ((IpAddress)ping_dest).getIpAddress() : null;
            if(host == null)
                throw new IllegalArgumentException("ping_dest is not of type IpAddress - FD_ICMP only works with these");
            try {
                if(log.isTraceEnabled())
                    log.trace("pinging " + host + " (ping_dest=" + ping_dest + ") using interface " + intf);
View Full Code Here

    private void acceptConnections(final ServerSocketChannel channel) throws IOException {
        // set to non blocking mode
        channel.configureBlocking(false);

        // Bind the server socket to the local host and port
        InetAddress host = InetAddress.getLocalHost();
        InetSocketAddress sockAddr = new InetSocketAddress(host, PORT);
        ServerSocket socket = channel.socket();
        //socket.setReuseAddress(true);
        socket.bind(sockAddr);
View Full Code Here

        ProtocolCodecFilter protocolFiler = new ProtocolCodecFilter(new ResponseEncoder(), new RequestDecoder());
        filterChainBuilder.addLast("protocol", protocolFiler);
        // and then a thread pool. REVIEWME
        filterChainBuilder.addLast("execFilter", new ExecutorFilter(ExecutorFactory.newCachedThreadPool("execFilter")));

        InetAddress host = InetAddress.getLocalHost();
        InetSocketAddress sockAddr = new InetSocketAddress(host, PORT);
        accepter.bind(sockAddr);

        if(JMX_MONITOR_ENABLED) {
            setupMonitor(accepter);
View Full Code Here

    // if it is localhost, we will assume there is only one
    // instance on this machine and then we will try and get the hostname from
    // the server.
    try {
      if (host == null || host.equals("localhost")) {
        InetAddress local = InetAddress.getLocalHost();
        host = local.getHostName();
      }
    } catch (UnknownHostException e) {
      logger.error("[getHostName] Cannot get hostname for localhost.", e);
      host = "UNKNOWN";
    }
View Full Code Here

                    dataSoc = new Socket();
                }

                dataSoc.setReuseAddress(true);

                InetAddress localAddr = resolveAddress(dataConfig
                        .getActiveLocalAddress());

                // if no local address has been configured, make sure we use the same as the client connects from
                if(localAddr == null) {
                    localAddr = ((InetSocketAddress)session.getLocalAddress()).getAddress();
                }      

                SocketAddress localSocketAddress = new InetSocketAddress(localAddr, dataConfig.getActiveLocalPort());
               
                LOG.debug("Binding active data connection to {}", localSocketAddress);
                dataSoc.bind(localSocketAddress);

                dataSoc.connect(new InetSocketAddress(address, port));
            } else {

                if (secure) {
                    LOG.debug("Opening secure passive data connection");
                    // this is where we wrap the unsecured socket as a SSLSocket. This is
                    // due to the JVM bug described in FTPSERVER-241.

                    // get server socket factory
                    SslConfiguration ssl = getSslConfiguration();
                   
                    // we've already checked this, but let's do it again
                    if (ssl == null) {
                        throw new FtpException(
                                "Data connection SSL not configured");
                    }

                    SSLSocketFactory ssocketFactory = ssl.getSocketFactory();

                    Socket serverSocket = servSoc.accept();

                    SSLSocket sslSocket = (SSLSocket) ssocketFactory
                            .createSocket(serverSocket, serverSocket
                                    .getInetAddress().getHostAddress(),
                                    serverSocket.getPort(), true);
                    sslSocket.setUseClientMode(false);

                    // initialize server socket
                    if (ssl.getClientAuth() == ClientAuth.NEED) {
                        sslSocket.setNeedClientAuth(true);
                    } else if (ssl.getClientAuth() == ClientAuth.WANT) {
                        sslSocket.setWantClientAuth(true);
                    }

                    if (ssl.getEnabledCipherSuites() != null) {
                        sslSocket.setEnabledCipherSuites(ssl
                                .getEnabledCipherSuites());
                    }

                    dataSoc = sslSocket;
                } else {
                    LOG.debug("Opening passive data connection");

                    dataSoc = servSoc.accept();
                }
               
                if (dataConfig.isPassiveIpCheck()) {
          // Let's make sure we got the connection from the same
          // client that we are expecting
          InetAddress remoteAddress = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
          InetAddress dataSocketAddress = dataSoc.getInetAddress();
          if (!dataSocketAddress.equals(remoteAddress)) {
            LOG.warn("Passive IP Check failed. Closing data connection from "
              + dataSocketAddress
              + " as it does not match the expected address "
              + remoteAddress);
            closeDataConnection();
View Full Code Here

            // 24-10-2007 - added check if PORT or PASV is issued, see
            // https://issues.apache.org/jira/browse/FTPSERVER-110
            DataConnectionFactory connFactory = session.getDataConnection();
            if (connFactory instanceof IODataConnectionFactory) {
                InetAddress address = ((IODataConnectionFactory) connFactory)
                        .getInetAddress();
                if (address == null) {
                    session.write(new DefaultFtpReply(
                            FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
                            "PORT or PASV must be issued first"));
View Full Code Here

TOP

Related Classes of java.net.InetAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.