Forum Thread: What Should I Know to Start Network Programming in C++?

What Should I Know to Start Network Programming in C++?

Hello, dear null-byte readers.

I am quite comfortable with the usage of C++, and I wish to start network programming. I've been learning about low level networking, yet I do not believe that I am on the right course. I would appreciate it if someone were to tell me what it is I need to know to start networking using C++. Also, I am looking for a powerful, high-level, user friendly and well documented library for C++ networking. I've been searching, and the most popular one seems to be the Boost:Asio library, yet there is no good documentation nor tutorials available. Thank you in advance.

10 Responses

Do you understand networking itself? The concepts?

A little bit, I've learned about protocols such as TCP, UDP, HTTP, HTTPS, FTP, SSH ... I know what IP addresses are, MAC addresses, what a DHCP server is, what ports are, what a socket is... anything else I need to know?

You should rather look into how socket programming works and how the networking API is used (in both server and client) to establish a connection. Then you should take a look at Beej's Guide to Network Programming.

Thank you so much! And by networking API, you mean? (Sorry if I sound like a noob)

Functions like socket, connect, accept, listen, gethostbyname.

Oh right. Thank you so much, you've been of great assistance!

Hi Gilgamesh,

When it comes to low level network programming you should better use C. The reason is that the interface provided by the OS is C based. That means that, in general, you will be writing C code, despite of using a C++ compiler.

Most network related libraries for C++, usually provides a higher level of abstraction. They are intended to build distributed application. In that case, the programmer wants as much network related problems solved as possible... because they will have enough fun just getting their specific application to work.

You may find the low level API exposed in some of those libraries (probably Boost provides that), but in that case you are just adding, at least, one layer of code to your application that you do not really need (we are talking low level programming).

Furthermore, any network related C++ library out there, is just a wrapper + utility classes around the BSD socket API.... there is no workaround as, as said above, that is the interface provided by the OS.

But it all depends on which kind of applications you want to build and what low level means to you. The Boost:Asio documentation is not bad (and I have to say that I'm not a big fun of Boost myself). That should be OK if you are looking for a proper C++ wrapper. From a C++ point of view will probably be the most correct one. The code looks awful to me, but that is just me.

You can also try zeromq , it has good documentation, but is not the best choice for building low level applications...

Everything else I know is really at a higher level and you go into all that serialization/interface definition languages/comms semantics/services.... and so on

Sorry for the long message, hope it helps

I'd advise against using any libraries for C++ such as Boost when you're beginning to learn about something. It takes away that essence from you due to its, as picoFlamingo has stated, abstracted layer which basically hides away all of that juicy lower level goodness that provides you with the proper understanding of how the protocols work. I guess that's one of the many reasons why C is such a nice language with which to work as it forces you to learn things to a certain extent and as a result, teaches you.

Further, abstracting things out yourself in C++ after learning is an even better next step.

You can learn network programming in less that 4 hours using this course:
Java Network Programming - Udemy ( www.udemy.com)

If your main programming language is C#, C++, Python or another OOP language you can still enroll, because the course is created for any student who knows a programming language.

After you will take this course you will be able to create complex network applications

Share Your Thoughts

  • Hot
  • Active