Fix README's examples to include headers as they are installed in a given system
This commit is contained in:
parent
c3bcc8f445
commit
ddfbbe5584
22
README.md
22
README.md
@ -14,7 +14,7 @@ Frnetlib is tested on both Linux and Windows and currently supports:
|
|||||||
# Connecting to a Socket:
|
# Connecting to a Socket:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <TcpSocket.h>
|
#include <frnetlib/TcpSocket.h>
|
||||||
|
|
||||||
fr::TcpSocket socket;
|
fr::TcpSocket socket;
|
||||||
if(socket.connect("127.0.0.1", "8081", std::chrono::seconds(10)) != fr::Socket::Status::Success)
|
if(socket.connect("127.0.0.1", "8081", std::chrono::seconds(10)) != fr::Socket::Status::Success)
|
||||||
@ -27,8 +27,8 @@ Here, we create a new fr::TcpSocket and connect it to an address. Simple. fr::Tc
|
|||||||
# Listening and accepting connections:
|
# Listening and accepting connections:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <TcpSocket.h>
|
#include <frnetlib/TcpSocket.h>
|
||||||
#include <TcpListener.h>
|
#include <frnetlib/TcpListener.h>
|
||||||
|
|
||||||
fr::TcpListener listener;
|
fr::TcpListener listener;
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ Here we create a new fr::TcpListener, which is used to listen for incoming conne
|
|||||||
# Using SSL
|
# Using SSL
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <SSLSocket.h>
|
#include <frnetlib/SSLSocket.h>
|
||||||
#include <SSLContext.h>
|
#include <frnetlib/SSLContext.h>
|
||||||
#include <SSLListener.h>
|
#include <frnetlib/SSLListener.h>
|
||||||
|
|
||||||
std::shared_ptr<fr::SSLContext> ssl_context(new fr::SSLContext()); //Creates a new 'SSL' context. This stores certificates and is shared between SSL enabled objects.
|
std::shared_ptr<fr::SSLContext> ssl_context(new fr::SSLContext()); //Creates a new 'SSL' context. This stores certificates and is shared between SSL enabled objects.
|
||||||
ssl_conext->load_ca_certs_from_file(filepath); //This, or 'load_ca_certs_from_memory' should be called on the context, to load your SSL certificates.
|
ssl_conext->load_ca_certs_from_file(filepath); //This, or 'load_ca_certs_from_memory' should be called on the context, to load your SSL certificates.
|
||||||
@ -71,7 +71,7 @@ SSLListener accepts a lot more arguments than its unencrypted counterpart, TcpLi
|
|||||||
# Sending packets:
|
# Sending packets:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <Packet.h>
|
#include <frnetlib/Packet.h>
|
||||||
|
|
||||||
fr::Packet packet;
|
fr::Packet packet;
|
||||||
packet << "Hello there, I am" << (float)1.2 << "years old";
|
packet << "Hello there, I am" << (float)1.2 << "years old";
|
||||||
@ -101,8 +101,8 @@ Effectively the reverse of sending packets. We call fr::TcpSocket::receive, pass
|
|||||||
# A simple HTTP server:
|
# A simple HTTP server:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <HttpRequest.h>
|
#include <frnetlib/HttpRequest.h>
|
||||||
#include <HttpResponse.h>
|
#include <frnetlib/HttpResponse.h>
|
||||||
|
|
||||||
fr::TcpSocket client; //fr::TcpSocket for HTTP. fr::SSLSocket for HTTPS.
|
fr::TcpSocket client; //fr::TcpSocket for HTTP. fr::SSLSocket for HTTPS.
|
||||||
fr::TcpListener listener; //Use an fr::SSLListener if HTTPS.
|
fr::TcpListener listener; //Use an fr::SSLListener if HTTPS.
|
||||||
@ -149,8 +149,8 @@ fr::HttpRequest objects are used for dealing with data being sent *to* the serve
|
|||||||
# A simple HTTP client:
|
# A simple HTTP client:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#include <HttpRequest.h>
|
#include <frnetlib/HttpRequest.h>
|
||||||
#include <HttpResponse.h>
|
#include <frnetlib/HttpResponse.h>
|
||||||
|
|
||||||
//Connect to the website example.com on port 80, with a 10 second connection timeout
|
//Connect to the website example.com on port 80, with a 10 second connection timeout
|
||||||
fr::TcpSocket socket;
|
fr::TcpSocket socket;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user