Coder Social home page Coder Social logo

marissamorrone / simple-websocket-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eidheim/simple-websocket-server

0.0 1.0 0.0 599 KB

A very simple, fast, multithreaded, platform independent WebSocket (WS) and WebSocket Secure (WSS) server and client library implemented using C++11, Boost.Asio and OpenSSL. Created to be an easy way to make WebSocket endpoints in C++.

License: MIT License

CMake 2.98% C++ 97.02%

simple-websocket-server's Introduction

Simple-WebSocket-Server

A very simple, fast, multithreaded, platform independent WebSocket (WS) and WebSocket Secure (WSS) server and client library implemented using C++11, Boost.Asio and OpenSSL. Created to be an easy way to make WebSocket endpoints in C++.

See also https://github.com/eidheim/Simple-Web-Server for an easy way to make REST resources available from C++ applications.

Features

  • RFC 6455 mostly supported: text/binary frames, ping-pong, connection close with status and reason.
  • Thread pool
  • Platform independent
  • WebSocket Secure support
  • Timeouts, if any of SocketServer::timeout_request and SocketServer::timeout_idle are >0 (default: SocketServer::timeout_request=5 seconds, and SocketServer::timeout_idle=0 seconds; no timeout on idle connections)
  • Simple way to add WebSocket endpoints using regex for path, and anonymous functions
  • An easy to use WebSocket and WebSocket Secure client library
  • C++ bindings to the following OpenSSL methods: Base64, MD5, SHA1, SHA256 and SHA512 (found in crypto.hpp)

###Usage

See ws_examples.cpp or wss_examples.cpp for example usage.

Dependencies

Boost C++ libraries must be installed, go to http://www.boost.org for download and instructions.

OpenSSL libraries from https://www.openssl.org are required.

Compile and run

ws_examples.cpp and wss_examples.cpp use C++14 features.

Compile with a C++14 compiler supporting regex (for instance g++ 4.9):

On Linux using g++: add -pthread

You can now also compile using CMake and make:

cmake .
make

WS

g++ -O3 -std=c++1y ws_examples.cpp -lboost_system -lcrypto -o ws_examples

Then to run the server and client examples: ./ws_examples

WSS

g++ -O3 -std=c++1y wss_examples.cpp -lboost_system -lssl -lcrypto -o wss_examples

Before running, an RSA private key (server.key) and an SSL certificate (server.crt) must be created. Follow, for instance, the instructions given here (for a self-signed certificate): http://www.akadia.com/services/ssh_test_certificate.html

Then to run the server and client examples: ./wss_examples

simple-websocket-server's People

Contributors

eidheim avatar dlinten avatar xhellerx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.