For a connected and autonomous vehicle (CAV), co-optimization of vehicle speed and powertrain operation maximizes the fuel benefits. For an internal combustion engine based vehicle (ICV), the transmission gear position can be optimized to adapt to anticipated future vehicle speed and power demand. It is necessary to consider drivability when optimizing the gear shift to ensure a satisfactory acceleration capability and to avoid the shift busyness. This work proposes a first-of-its-kind real-time implementable optimal control strategy to optimize vehicle speed and gear position simultaneously for ICVs while considering both fuel efficiency and drivability. The control strategy is developed upon a unified CAV framework so that it is widely applicable to various CAV applications. The optimal control problem is formulated and simplified to a mixed integer programming problem with a convex quadratic objective function and linear constraints. An efficient numerical solver is applied to obtain the optimal solutions for an eco-drive application in a model predictive control (MPC) fashion. The control is real-time implementable with an average computational time of 0.33 seconds and maximum computational time of 0.79 seconds. Results from simulation and experiment show that by co-optimizing vehicle speed and gear position, the target vehicle can achieve 16% fuel benefits compared to a baseline vehicle with constant speed cruising control. In addition, experimental results show that the optimal control can also significantly reduce emissions.