When you are rubbing the wool socks on the carpet, you are transferring electrons. When you touch the metal doorknobs, the electron levels are then going back to normal. The rush of electrons causes the shock.
when u vigorously rub ur wool socks on the carpet floor touch a metal door knob and get shocked all the electronds from your socks and the metal door combine together making a shock