Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Platform C++ Networking (without big library)

Tags:

c++

networking

I think it is better if I explain the situation so this doesn't seem too arcane a question. I want to release some starter code for a project I want some of my students to work on. The project involves scraping through some internet webpages and as such, I want to provide them with a URLStream class that will download the html of an input url and return it as a string to them.

The issue is that I can't seem to find a particularly nice way to deal with networking in a way that will be cross platform (the students have mac/windows/linux machines). I know of libraries like Boost asio and libCurl, but the issue with using these is that I can't enforce all my students download them. So my question is twofold:

  1. Is there any nice way to provide them this cross platform networking code?
  2. If a library is the only way to do this, is there any way to attach the library to the starter project so that students don't have to download it? I know this might be a stupid question but I can't seem to find out if this is possible.
like image 679
gowrath Avatar asked Apr 21 '17 08:04

gowrath


People also ask

Is wxWidgets cross-platform?

wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.

What is CPP Netlib?

cpp-netlib is a collection of network-related routines/implementations geared towards providing a robust cross-platform networking library.

What type application do we produce with wxWidgets?

wxWidgets is a C++ library that lets developers create applications for Windows, macOS, Linux and other platforms with a single code base.


1 Answers

Boost.Asio is really not suitable for your needs as it involves huge Boost and building at least some of its non-header-only libs. You can still consider Asio lib that can be used w/o Boost and is header-only lib, so much less hassle for you and your students. As it's probably the most popular and modern networking C++ lib this exercise can provide some useful experience to the students. Asio examples also have a simple HTTP client.

As a side note, are you bound to C++ for this assignment? It would be much simpler in Python or similar languages that provide networking out of the box.

like image 192
Andriy Tylychko Avatar answered Sep 23 '22 17:09

Andriy Tylychko