Package java.net

Examples of java.net.InetSocketAddress


    String varVal = null;

    // client ip
    if (varName.equals(CLIENT_IP)) {
      if (session.getRemoteAddress() instanceof InetSocketAddress) {
        InetSocketAddress remoteSocketAddress = (InetSocketAddress) session.getRemoteAddress();
        varVal = remoteSocketAddress.getAddress().getHostAddress();
      }

    }

    // client connection time
View Full Code Here


    String varVal = null;

    SocketAddress localSocketAddress = session.getLocalAddress();

    if (localSocketAddress instanceof InetSocketAddress) {
      InetSocketAddress localInetSocketAddress = (InetSocketAddress) localSocketAddress;
      // server address
      if (varName.equals(SERVER_IP)) {

        InetAddress addr = localInetSocketAddress.getAddress();

        if (addr != null) {
          varVal = addr.getHostAddress();
        }
      }

      // server port
      else if (varName.equals(SERVER_PORT)) {
        varVal = String.valueOf(localInetSocketAddress.getPort());
      }
    }

    return varVal;
  }
View Full Code Here

                                    "EPRT.invalid", null));
            return;
        }

        session.getDataConnection().initActiveDataConnection(
                new InetSocketAddress(dataAddr, dataPort));
        session.write(LocalizedFtpReply.translate(session, request, context,
                FtpReply.REPLY_200_COMMAND_OKAY, "EPRT", null));
    }
View Full Code Here

            session.write(LocalizedFtpReply.translate(session, request, context,
                FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT.disabled", null));
            return;
        }

        InetSocketAddress address;
        try {
            address = SocketAddressEncoder.decode(request.getArgument());
           
            // port must not be 0
            if(address.getPort() == 0) {
              throw new IllegalPortException("PORT port must not be 0");
            }
        } catch (IllegalInetAddressException e) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
            return;
        } catch (IllegalPortException e) {
            LOG.debug("Invalid data port: " + request.getArgument(), e);
            session
                    .write(LocalizedFtpReply
                            .translate(
                                    session,
                                    request,
                                    context,
                                    FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
                                    "PORT.invalid", null));
            return;
        } catch (UnknownHostException e) {
            LOG.debug("Unknown host", e);
            session
                    .write(LocalizedFtpReply
                            .translate(
                                    session,
                                    request,
                                    context,
                                    FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
                                    "PORT.host", null));
            return;
        }

        // check IP
        if (dataCfg.isActiveIpCheck()) {
            if (session.getRemoteAddress() instanceof InetSocketAddress) {
                InetAddress clientAddr = ((InetSocketAddress) session
                        .getRemoteAddress()).getAddress();
                if (!address.getAddress().equals(clientAddr)) {
                    session.write(LocalizedFtpReply.translate(session, request,
                            context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT.mismatch", null));
                    return;
                }
            }
View Full Code Here

    private SocketUtils() {}

    public static Socket openSocket(InetAddress addr, int port, int connectTimeout, long pollDelay, int maxRetry)
            throws IOException {
        SocketAddress sockAddr = new InetSocketAddress(addr, port);
        return openSocket(sockAddr, connectTimeout, pollDelay, maxRetry);
    }
View Full Code Here

        return openSocket(sockAddr, connectTimeout, pollDelay, maxRetry);
    }

    public static Socket openSocket(String host, int port, int connectTimeout, long pollDelay, int maxRetry)
            throws IOException {
        SocketAddress sockAddr = new InetSocketAddress(host, port);
        return openSocket(sockAddr, connectTimeout, pollDelay, maxRetry);
    }
View Full Code Here

  private SocketServerConnectionFactory sscf;
  private InetSocketAddress addr;
  private MemoryStorageManager storageManager;

  @Before public void setUp() {
    addr = new InetSocketAddress(0);
  }
View Full Code Here

   
    ClientServiceRegistryImpl server;
    private ResultsReceiver<Object> listener;

    public FakeClientServerInstance(ClientServiceRegistryImpl server) throws UnknownHostException {
      super(new HostInfo("foo", new InetSocketAddress(InetAddress.getLocalHost(), 1)), 1000);
      this.server = server;
    }
View Full Code Here

    SSLConfiguration config = new SSLConfiguration();
    Properties p = new Properties();
    SocketServerConnection conn = helpEstablishConnection(false, config, p);
    assertTrue(conn.isOpen(1000));
    //restart the second instance now that we know the connection was made to the first
    listener1 = createListener(new InetSocketAddress(addr.getAddress(), listener1.getPort()), config);
    listener.stop();
    conn.isOpen(1000); //there is a chance this call can fail
    assertTrue(conn.isOpen(1000));
    listener1.stop();
    //both instances are down
    assertFalse(conn.isOpen(1000));
    //bring the first back up
    listener = createListener(new InetSocketAddress(addr.getAddress(), listener.getPort()), config);
    assertTrue(conn.isOpen(1000));
    assertEquals(3, logonAttempts);
    conn.close();
  }
View Full Code Here

    assertEquals(expectedPayload.length()+"", response.getFirstHeader("Content-Length").getValue());
  }

  @Test
  public void sendGarbageTest() throws IOException {
    InetSocketAddress socketAddress = new InetSocketAddress(PORT);
    SocketChannel channel = SocketChannel.open(socketAddress);
    channel.write(
        ByteBuffer.wrap(
            new byte[] {1, 1, 1, 1// garbage
        )
View Full Code Here

TOP

Related Classes of java.net.InetSocketAddress

Copyright © 2015 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.