Code example for Socket

Methods: getInputStream, getOutputStream, setKeepAlive

0
    public void setSocket(Socket socket) {
	this.socket = socket;
	if (socket != null) {
	    try { 
		reader = new BufferedReader
		    (new InputStreamReader(socket.getInputStream()));
		writer = new DataOutputStream(socket.getOutputStream());
                socket.setKeepAlive(true);
                // socket.setSoTimeout(5000); 
	    } catch (IOException ioe) {
		ioe.printStackTrace();
		throw new Error();
	    } 
	} 
    } 
 
 
    /** 
     * Returns the socket used. 
     * 
     * @return the socket used