I usually heat both pipe and fitting, probably 2/3 of the time heating the pipe, and 1/3 heating the fitting, and try to keep the centre of the flame away from the mouth of the socket, where the flux is.
Ideally you want the piece of pipe inside the fitting and the socket around it to reach soldering temperature simultaneously. If you just heat the fitting you are relying on conduction from the small mass of the fitting through a few contact points to heat the relatively large mass of pipe, made worse as the hotter fitting expands more than the cooler pipe, reducing the area of close contact. Heat the pipe, and that expands more, and grips the fitting a bit tighter.
IME solder and brazing alloys tend to flow towards the hottest part of the job, not the torch flame itself (though admittedly the hottest part is usually the part directly in the torch flame).
Ideally you want the piece of pipe inside the fitting and the socket around it to reach soldering temperature simultaneously. If you just heat the fitting you are relying on conduction from the small mass of the fitting through a few contact points to heat the relatively large mass of pipe, made worse as the hotter fitting expands more than the cooler pipe, reducing the area of close contact. Heat the pipe, and that expands more, and grips the fitting a bit tighter.
IME solder and brazing alloys tend to flow towards the hottest part of the job, not the torch flame itself (though admittedly the hottest part is usually the part directly in the torch flame).