Mode is a safety-critical function, and as such cannot be controlled from inside program code.
The Submit interpreters in KSS cannot execute motion commands (barring specifically-configured Async external axes), or commands that influence motion in realtime (changing $TOOL or $BASE, for example), with the sole exception of $OV_PRO and $OV_APPL.
Note: controlling $OV_PRO from the Submit is not advised.
An SPS program running an EKI channel in server mode could "listen" for input values from a PC, and execute specific commands based on those incoming variable values.
In this case, is there anyway to execute a motion command of Kuka after I send a command from my PC client through TCP socket?