IoT CAS Frameworks/IOT_Server/Multi-point_Event_Router_Framework/Event_Receiver_Mapper/EventReceiverMapper/src/com/prokosha/eventreceivermapper/EventProcessor.java
public boolean init() {
        if (gszEventProcessorName.equalsIgnoreCase("etl")) {
            if (ETLInitialized) {
                return true;
            } else {
                return false;
            }
        }
        //System.out.println("Initializing Socket, PrintWriter for host : " + gszEventProcessorHost + "...............");
        FundamentalBlock:
        {
            SocketChannel ssc = null;
            try {
                ssc = SocketChannel.open();
                InetSocketAddress isa = new InetSocketAddress(InetAddress.getByName(gszEventProcessorHost), iport);
                skt = ssc.socket();
                skt.connect(isa);
                //ssc.configureBlocking(false); // active polling mode
                if (skt == null) {
                    System.out.println("socket is null");
                }
                out = skt.getOutputStream();
                //skt.getChannel().
                //skt.setOOBInline(true);
                //skt.setTcpNoDelay(true);
                skt.setReuseAddress(true);
                writer = new PrintWriter(out, true);
                entered = true;
                openPortCount++;
                System.out.println("Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " successful");
                return true;
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " failed");
                System.out.println("Exception: connecting to " + gszEventProcessorHost + "@" + gszEventProcessorPort + " failed");
                entered = false;
                //System.out.println("Closing Socket and PrintWriter for host : " + gszEventProcessorHost + "...........");
                try {
                    entered = false;
                    if (skt != null) {
                        skt.close();
                    }
                    skt = null;
                } catch (Exception ex1) {
                    ex1.printStackTrace();
                }
                return false;
            }
        }
    }
/**
     * initialize connections to the mapped host.
     */
initialize connections to the mapped host.
initialize connections to the mapped host .
public boolean init() {
        if (gszEventProcessorName.equalsIgnoreCase("etl")) {
            if (ETLInitialized) {
                return true;
            } else {
                return false;
            }
        }
        FundamentalBlock:
        {
            SocketChannel ssc = null;
            try {
                ssc = SocketChannel.open();
                InetSocketAddress isa = new InetSocketAddress(InetAddress.getByName(gszEventProcessorHost), iport);
                skt = ssc.socket();
                skt.connect(isa);
                if (skt == null) {
                    System.out.println("socket is null");
                }
                out = skt.getOutputStream();
                skt.setReuseAddress(true);
                writer = new PrintWriter(out, true);
                entered = true;
                openPortCount++;
                System.out.println("Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " successful");
                return true;
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " failed");
                System.out.println("Exception: connecting to " + gszEventProcessorHost + "@" + gszEventProcessorPort + " failed");
                entered = false;
                try {
                    entered = false;
                    if (skt != null) {
                        skt.close();
                    }
                    skt = null;
                } catch (Exception ex1) {
                    ex1.printStackTrace();
                }
                return false;
            }
        }
    }
public boolean init ( ) { if ( gszEventProcessorName . equalsIgnoreCase ( "etl" ) ) { if ( ETLInitialized ) { return true ; } else { return false ; } } FundamentalBlock : { SocketChannel ssc = null ; try { ssc = SocketChannel . open ( ) ; InetSocketAddress isa = new InetSocketAddress ( InetAddress . getByName ( gszEventProcessorHost ) , iport ) ; skt = ssc . socket ( ) ; skt . connect ( isa ) ; if ( skt == null ) { System . out . println ( "socket is null" ) ; } out = skt . getOutputStream ( ) ; skt . setReuseAddress ( true ) ; writer = new PrintWriter ( out , true ) ; entered = true ; openPortCount ++ ; System . out . println ( "Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " successful" ) ; return true ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; System . out . println ( "Initialization of Socket, PrintWriter for host : " + gszEventProcessorHost + " failed" ) ; System . out . println ( "Exception: connecting to " + gszEventProcessorHost + "@" + gszEventProcessorPort + " failed" ) ; entered = false ; try { entered = false ; if ( skt != null ) { skt . close ( ) ; } skt = null ; } catch ( Exception ex1 ) { ex1 . printStackTrace ( ) ; } return false ; } } }
initialize connections to the mapped host.
initialize connections to the mapped host .
//System.out.println("Initializing Socket, PrintWriter for host : " + gszEventProcessorHost + "..............."); //ssc.configureBlocking(false); // active polling mode //skt.getChannel(). //skt.setOOBInline(true); //skt.setTcpNoDelay(true); //System.out.println("Closing Socket and PrintWriter for host : " + gszEventProcessorHost + "...........");