Code example for Socket

Methods: connectgetInputStreamgetOutputStreamisConnected

0
			strState = "on"; 
		} 
        try 
        { 
            SocketAddress saddr = new InetSocketAddress("192.168.0.55", 9001);
            nsocket = new Socket();
            nsocket.connect(saddr, 9001); //10 second connection timeout
            if (nsocket.isConnected()) {
            	String cmd = "\"" + strNode + " " + strState + "\"";
                nis = nsocket.getInputStream();
                nos = nsocket.getOutputStream();
                nos.write(cmd.getBytes());
        		btnState = ButtonPress(btnSw,btnState,strNode);
            }  
        } 
        catch (IOException e)
        { 
            // TODO Auto-generated catch block 
            e.printStackTrace();
        }  
Contextual code suggestions in your IDE  Get Codota for Java