0

I am quite new to network programming and I would like to create a simple non-blocking TCP server class in C++. After searching, I saw that I can implement it using Berkeley Sockets API or I can use external libraries such as Boost.Asio or POCO.

My question is, what are the pros and cons of using those libraries over Berkeley sockets API?

EDIT: To be more specific, I am not looking for what will be more easy to work with, as this is individual opinion I guess. I am looking for facts such as performance? dealing with multi-threading? and maybe other aspects from expirienced programmers.

A. Sarid
  • 3,916
  • 2
  • 31
  • 56

1 Answers1

2

Use BSAPI if you want to use C from C++. I don't recommend it as a work habit, but it might help you to better grasp the nature of tcp/ip/c-language. Downside is you'll have to... write C. Or search for wrapper libraries. Or write your own wrapper.

Use Boost::Asio/POCO if you want to code in C++ (using C++).

Use more high level libraries if you need to code fast.

here's another answer, though: Socket API or library for C++?

Community
  • 1
  • 1
strangeqargo
  • 1,276
  • 1
  • 15
  • 23
  • 3
    I agree with this statement, "Use more high level libraries if you need to code fast[,]" with a caveat: If you don't know how to use the high-level library, you probably aren't going to get much of a reduction in coding time. – user4581301 Apr 25 '16 at 18:42
  • Though good high-level library typically allows to complete common tasks faster and low-level tasks safer. – strangeqargo Apr 25 '16 at 19:32
  • 2
    Definitely not going to argue that. The kicker is good library. POCO I've never used. ASIO is pretty good, but the weird factor is fantastic if you've been raised on Berkeley sockets and C or know nothing. The real beauty comes somewhere around the third time you use a library. – user4581301 Apr 25 '16 at 20:33