In your circuit you are using only P2 for relay control and in switch statement you are assigning the processed data to P0, P1, P2 and P3 based on case value. You only have to assign the processed value to P2.
If you are not sending \r\n at the end of the serial data then you just need one byte variable to hold the serial data and it can be directly assigned to P2 without the need of switch statement if received data is integer data. If received data is ascii character then you have to subtract 0x30 from it.
Also you have to use 15 pf Capacitors for the Oscillator Circuit.
Are you using 12 MHz Crystal or 11.0592 MHz Crystal ?
Do you just want to assign 1 byte data to relay port to control it ?
During Port initialization before while(1) loop you have to use
The it is very easy. You have to receive 2 bytes in the Serial Interrupt. and you have to stop reception when 0xFE is received then assign the second byte received to Px based on 1st byte value.
I don't have Keil C51 and hence I have written code in mikroC PRO 8051. You can easily port the code to C51. Use Serial Interrupt for receiving data.