Skip to content

boomanaiden154/websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Websocket - A header only websocket client library for C++

A simple header only library that implements a websocket client in c++

Usage:

See examples in the ./examples directory.

#include <iostream>
#include "websocket.hpp"

void listen(char* data, int length)
{
    printf("testing:%s\n",data);
    std::cout << length << std::endl;
}

int main()
{
    websocket test;
    void (*listener)(char*, int) = listen;
    test.connectSocket("127.0.0.1", 8081, listen);
    test.sendMessage("testing:whatthebif");
    std::cout << "Sent message" << std::endl;
    test.exit();
}

Compiling

When compiling with websocket.hpp, make sure to link pthread and OpenSSL as this library uses these libraries to allow for sending and receiving of data at the same time, and for secure websockets. Using g++ for example:

g++ yourFile.cpp -lpthread -lssl -o yourOutput 

About

Simple C++ header only websocket library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages