Code example for InetSocketAddress

0
    private void connectSocket(InetAddress ina, int port) {
        // Create the socket 
        try { 
            SocketChannel socket = SocketChannel.open();
            socket.configureBlocking(false);
            socket.connect(new InetSocketAddress(ina, port));
            Data data = new Data();
            data.port = port;
            data.start = System.nanoTime();
            socket.register(selector, SelectionKey.OP_CONNECT, data);
        } catch (IOException e) {
            Log.e(TAG, e.getMessage());
        } 
    } 
 
    protected void onCancelled() { 
        select = false;
    } 
 
    private void closeSelector() { 
        try {