public void close()
	{
		if (readyState == ReadyState.Closing || readyState == ReadyState.Closed)
		{
			return;
		}
		
		if (readyState == ReadyState.Open)
		{
			// send termination char to server (fake closing handshake)
			out.write(0xFF);
			out.flush();
		}
			
		readyState = ReadyState.Closing;			
	
		try
		{
			if (in != null)
				in.close();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
		
		try
		{
			if (out != null)
				out.close();
		} catch (Exception e)
		{
			e.printStackTrace();
		}
		
		try
		{
			if (socket != null)
				socket.close();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
		
		readyState = ReadyState.Closed;
		handleClose();
	}