Server and Client on one instance of a game

Yes, you can. You can have even one server and multiple clients in the same machine. The code from this should be a good starting points. You can check the library documentation and see if it suits your needs.

Kf