Package java.net

Examples of java.net.SocketAddress


   *            of the neighbour that will receive the list.
   */
  public void sendNeighborsListToNeigh(int port , int neighbour) {
    char[] resp = null;

    SocketAddress neighbourAddress = new InetSocketAddress("localhost",
        port);
    resp = new String("DELET " + this.port).toCharArray();
    DatagramPacket answer = null;
    try {
//      answer = new DatagramPacket(resp, resp.length, neighbourAddress);
//      this.socket.send(answer);
      channel.send(Charset.forName("ascii").encode(
          CharBuffer.wrap(resp)), neighbourAddress);

       
    } catch (SocketException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    if(port != neighbour){
    resp = new String("ADD_PORT " + neighbour).toCharArray();

        try {

          channel.send(Charset.forName("ascii").encode(
              CharBuffer.wrap(resp)), neighbourAddress);
          //this.socket.send(answer);
        } catch (SocketException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        resp = new String("ADD_PORT " + port).toCharArray();
        SocketAddress neighbourAddress1 = new InetSocketAddress("localhost",
            neighbour);

        try {

          channel.send(Charset.forName("ascii").encode(
View Full Code Here


//      ExecutorService exec = Executors.newFixedThreadPool(100);

      while (!this.isInterrupted()) {
        final ByteBuffer buffer = ByteBuffer.allocate(64*1028);
        try {
          final SocketAddress sender = channel.receive(buffer);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        buffer.flip();
View Full Code Here

      return keys.get(remoteAddress);
    }
  }

  public PublicKey getDiscoveredKey(InetAddress addr) {
    SocketAddress socketAddress = new InetSocketAddress(addr, SSH_PORT);
    return getDiscoveredKey(socketAddress);
  }
View Full Code Here

   @Test(dependsOnMethods = "testCorrectSetup")
   public void testHashFunctionReturnsSameValues() {
      for (int i = 0; i < 1000; i++) {
         byte[] key = generateKey(i);
         TcpTransport transport = (TcpTransport) tcpConnectionFactory.getTransport(key);
         SocketAddress serverAddress = transport.getServerAddress();
         CacheContainer cacheContainer = hrServ2CacheManager.get(serverAddress);
         assertNotNull("For server address " + serverAddress + " found " + cacheContainer + ". Map is: " + hrServ2CacheManager, cacheContainer);
         DistributionManager distributionManager = cacheContainer.getCache().getAdvancedCache().getDistributionManager();
         Address clusterAddress = cacheContainer.getCache().getAdvancedCache().getRpcManager().getAddress();
View Full Code Here

        try {

            logger.debug("Connecting to guacd at {}:{}.", hostname, port);

            // Get address
            SocketAddress address = new InetSocketAddress(
                    InetAddress.getByName(hostname),
                    port
            );

            // Connect with timeout
View Full Code Here

            logger.debug("Connecting to guacd at {}:{} via SSL/TLS.",
                    hostname, port);

            // Get address
            SocketAddress address = new InetSocketAddress(
                InetAddress.getByName(hostname),
                port
            );

            // Connect with timeout
View Full Code Here

   *            of the neighbour that will receive the list.
   */
  public void sendNeighborsListToNeigh(int port) {
    byte[] resp = null;

    SocketAddress neighbourAddress = new InetSocketAddress("localhost",
        port);
    for (byte b : resp) {

    }
    for (int portNei : portNeighbours) {
View Full Code Here

        assert host != null;
        assert port >= 0;
        if (connector == null) {
            throw new IllegalStateException("SshClient not started. Please call start() method before connecting to a server");
        }
        SocketAddress address = new InetSocketAddress(host, port);
        return connect(address);
    }
View Full Code Here

        I_S = receiveKexInit(buffer, serverProposal);
    }

    private void checkHost() throws SshException {
        ServerKeyVerifier serverKeyVerifier = getClientFactoryManager().getServerKeyVerifier();
        SocketAddress remoteAddress = ioSession.getRemoteAddress();

        if (!serverKeyVerifier.verifyServerKey(this, remoteAddress, kex.getServerKey())) {
            throw new SshException("Server key did not validate");
        }
    }
View Full Code Here

  public ServerContext createContext(TProtocol input, TProtocol output, Object selectionKeyObject) {
    LOG.debug("Client connected");
    SelectionKey selectionKey = (SelectionKey) selectionKeyObject;
    SocketChannel channel = (SocketChannel) selectionKey.channel();
    Socket socket = channel.socket();
    SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
    SocketAddress localSocketAddress = socket.getLocalSocketAddress();
    _connectionMeter.mark();
    _connections.incrementAndGet();
    return new ShardServerContext(localSocketAddress, remoteSocketAddress);
  }
View Full Code Here

TOP

Related Classes of java.net.SocketAddress

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.