Package java.net

Examples of java.net.InetSocketAddress


  public void bind (Selector selector, int localPort) throws IOException {
    close();
    try {
      datagramChannel = selector.provider().openDatagramChannel();
      datagramChannel.socket().bind(new InetSocketAddress(localPort));
      datagramChannel.configureBlocking(false);
      selectionKey = datagramChannel.register(selector, SelectionKey.OP_READ);

      lastCommunicationTime = System.currentTimeMillis();
    } catch (IOException ex) {
View Full Code Here


    close();
    synchronized (updateLock) {
      selector.wakeup();
      try {
        serverChannel = selector.provider().openServerSocketChannel();
        serverChannel.socket().bind(new InetSocketAddress(tcpPort));
        serverChannel.configureBlocking(false);
        serverChannel.register(selector, SelectionKey.OP_ACCEPT);
        if (DEBUG) debug("kryonet", "Accepting connections on port: " + tcpPort + "/TCP");

        if (udpPort != -1) {
View Full Code Here

            continue;
          }

          // Must be a UDP read operation.
          if (udp == null) continue;
          InetSocketAddress fromAddress;
          try {
            fromAddress = udp.readFromAddress();
          } catch (IOException ex) {
            if (WARN) warn("kryonet", "Error reading UDP data.", ex);
            continue;
          }
          if (fromAddress == null) continue;

          Connection[] connections = this.connections;
          for (int i = 0, n = connections.length; i < n; i++) {
            Connection connection = connections[i];
            if (fromAddress.equals(connection.udpRemoteAddress)) {
              fromConnection = connection;
              break;
            }
          }
View Full Code Here

  public ConnectionEndpoint
  getEndpoint()
  {
      // make up a vaguely usable endpoint

    return( new ConnectionEndpoint(new InetSocketAddress( peer.getIp(), peer.getPort())));
  }
View Full Code Here

    } else if (core_transport instanceof UDPTransport) {
      TransportHelperFilter hfilter = ((UDPTransport)core_transport).getFilter();
      if (hfilter != null) {helper = hfilter.getHelper();}
      else {
        helper = ((UDPTransport)core_transport).getFilter().getHelper();
        InetSocketAddress addr = core_transport.getTransportEndpoint().getProtocolEndpoint().getConnectionEndpoint().getNotionalAddress();
        if (!connection.isIncoming()) {
        try {helper = new UDPTransportHelper(UDPNetworkManager.getSingleton().getConnectionManager(), addr, (UDPTransport)core_transport);}
        catch (IOException ioe) {throw new TransportException(ioe);}
        }
        else {
View Full Code Here

   
      throws IOException
    {
      ByteArrayOutputStream  os = new ByteArrayOutputStream( 1024 );
     
      InetSocketAddress  local_address = null// TODO
     
      processRequest(input_header, lowercase_input_header, url_path, local_address, remote_address, announce_and_scrape_only, false, is, os, async );
     
      return( os );
    }
View Full Code Here

            };
            thread.start();
            Thread.sleep(1000);
            Socket socket = new Socket();
            socket.setSoTimeout(2000);
            InetSocketAddress socketAddress = new InetSocketAddress(address, port);
            System.out.println("client:" + socketAddress);
            try {
                socket.connect(socketAddress, 2000);
                Thread.sleep(200);
                System.out.println("client:" + socket.toString());
View Full Code Here

          String serverPort = serverElement.attributeValue("port", "8005");
          String shutdownCommand = serverElement.attributeValue("shutdown", "SHUTDOWN");
         
          // send shutdown command to specified port
          Socket socket = new Socket();
          socket.connect(new InetSocketAddress("127.0.0.1", Integer.parseInt(serverPort)), 1000);
          socket.setSoTimeout(5000);
                  OutputStream stream = socket.getOutputStream();
                  for (int i = 0; i < shutdownCommand.length(); i++) {
                      stream.write(shutdownCommand.charAt(i));
                  }
View Full Code Here

                                           new ProtocolCodecFilter( new ObjectSerializationCodecFactory() ) );

        acceptor.setHandler( handler );
        acceptor.getSessionConfig().setReadBufferSize( 2048 );
        acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
        acceptor.bind( new InetSocketAddress( localInterface, port ) );
        running = true;
    }
View Full Code Here

        return connect();
    }

  public boolean connect(String address, int port) {
    this.connector = new NioSocketConnector();
        this.address = new InetSocketAddress( address, port );
        this.connector.setHandler( this.handler );
        return connect();
  }
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.