Yes. For example when I was younger I ran a Jedi Academy server on my Windows XP computer which operated on some port. When I played the game online, it chose a different port.
You just need to launch the game twice, once for a server and again for a client. Or, sometimes games come with a way of hosting a dedicated server separate from the game's programming. It all depends on the game.