Your best bet is to use an existing server, and add your functionality to it. Writing an entire server from scratch, even using a library, is going to be a lot harder than you expect.
Can you tell us more about the problem you are trying to solve? We can then point you to an appropriate server, and help you with the right place to plug in.