Server and Client on one instance of a game

So basically, I have to make:
A server, that handles calculations, data and incoming input.
Client, that handles drawing, interactions with mouse, screen, keyboard etc. and sending user input.

Then I can make multi-platform game, that will differ in controls and have the same features. This is useful, because I have to make the game code only for the server.

Also, question:
Can I have a client connected to a server on the same device?