In fact, there is nothing to set the standard output 8051 as input; all contacts are always bi-directional.
However, if you write β0β to the pin, it will enable the open-drain driver, and there is no way that anything external could ever force it anything other than β0β, so the input will only read β0β - regardless from an external signal that you might want to read.
But if you write β1β to the pin, it will turn off the open drain driver and thus the external signal can output the pin either high or low - and the input can read the state of the external signal.
Everything is explained in chapter 3 of the Bible for 8051:
Chapter 3 - Description of the 80C51 Family Hardware: http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf
Start reading p2, βStructure and Operation of the Port,β and pay particular attention to Figures 4 and 5.
source share