Search code examples
c++socketsncursesevent-driven

Writing a console-based C++ IRC-client


I'm learning C++ and so I've decided to begin coding a IRC-Client.

I basically want it to be consolebased, and I've looked in to libraries such as ncurses, but I don't really know whether or not this would be the best approach.

I imagine the UI being divided into one part where whatever messages are written appear, and one part where the users input goes. Ncurses seemed to be able to do this, but now I've discovered another issue.

Because I want the message-part to be event driven (whenever somebody sends a message, this should appear in the message-part) the message-part of the UI should run independently from the input-part. Also, sockets would have to be non-blocking as well.

I've looked around on the internet and haven't found any good tutorials on this, as most are either really, really old, poorly written or simply just to long.

Anyways, my questions are, how would this be done using the ncurses and socket libraries? Are their any good C++ wrappers (one thing I've learned from reading ncurses tutorials is that OOP is really wonderful...)?


Solution

  • Using ncurses for the interface sounds like a good idea. You can do a single-threaded select-based network and terminal client -- check out Beej's guide. Alternatively, Boost.asio, single-or-multithreaded, should be a solid choice, too.