Skip to content
프로젝트

소개

WebSocket을 지원하는 간단하고 작은 C++ 임베디드용 웹 서버입니다.

웹 및 앱

이 수치를 측정하는 방법

What you can do

  • Serves static content from disk
  • API for building WebSocket servers
  • Simple command line binary for quick serving of static files only
  • Supports newer Hybi-10 and Hybi-16 WebSockets as well as the older Hixie style.

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Seasocks - A tiny embeddable C++ HTTP and WebSocket server

CI codecov GitHub release License ConanCenter package

Features

  • Simple C++ API
  • Serves static content from disk
  • API for building WebSocket servers
  • Simple command line binary for quick serving of static files only
  • Supports newer Hybi-10 and Hybi-16 WebSockets as well as the older Hixie style.
  • Supports Linux and Windows

Stuff it doesn't do

  • It's not nearly as configurable as Apache, Lighttpd, Nginx, Jetty, etc.
  • It provides only limited support for custom content generation (e.g. Servlets).
  • It has been designed for WebSocket based control.
  • It probably won't work on other systems (patches to support other systems would be welcome, but not a priority for us)

Intended use and security

Seasocks is for internal tools and trusted environments: control and monitoring UIs, embedded devices, development and test setups. It is not designed for untrusted environments, and it should not be exposed directly to the internet.

It has no TLS support, any authentication is left to your own handlers, and security hardening is not a goal of the project. Some basic safeguards exist (for example, static file requests can't climb out of the static directory with ..), but its request handling isn't designed to withstand hostile clients, so assume that one on the network can cause trouble. If you need to serve untrusted clients, put Seasocks behind a reverse proxy (nginx, Caddy, etc.) that provides TLS, authentication and request limits.

Getting started

Check out the tutorial on the wiki.

See src/app/c/ws_test.cpp for an example.

Using Seasocks in your CMake project

Seasocks needs a C++17 compiler.

Installed

Configure, build and install Seasocks:

cmake -S . -B build -DUNITTESTS=OFF -DSEASOCKS_EXAMPLE_APP=OFF
cmake --build build
cmake --install build --prefix <dir>

Without --prefix the install goes to /usr/local, which usually needs root, so a directory you can write to is normally what you want. This installs the library, the public headers under include/seasocks, the Seasocks CMake package files under lib/cmake/Seasocks, and the LICENSE.

Then find it and link against the Seasocks::seasocks target, adding the prefix to CMAKE_PREFIX_PATH (for example -DCMAKE_PREFIX_PATH=<dir>) if it is not a standard location:

find_package(Seasocks REQUIRED)
add_executable(my_server serve.cpp)
target_compile_features(my_server PRIVATE cxx_std_17)
target_link_libraries(my_server PRIVATE Seasocks::seasocks)

Built as part of your project

Each of these builds Seasocks alongside your code, so there is nothing to install. The link line is always the same as above.

With add_subdirectory on a copy of the source (for example a git submodule in thirdparty/seasocks):

set(UNITTESTS OFF CACHE INTERNAL "")
set(SEASOCKS_EXAMPLE_APP OFF CACHE INTERNAL "")
add_subdirectory(thirdparty/seasocks)
target_compile_features(my_server PRIVATE cxx_std_17)
target_link_libraries(my_server PRIVATE Seasocks::seasocks)

With FetchContent:

include(FetchContent)
set(UNITTESTS OFF CACHE INTERNAL "")
set(SEASOCKS_EXAMPLE_APP OFF CACHE INTERNAL "")
FetchContent_Declare(seasocks
    GIT_REPOSITORY https://github.com/mattgodbolt/seasocks.git
    GIT_TAG v1.4.6)
FetchContent_MakeAvailable(seasocks)
target_compile_features(my_server PRIVATE cxx_std_17)
target_link_libraries(my_server PRIVATE Seasocks::seasocks)

With CPM.cmake:

CPMAddPackage(
    NAME seasocks
    GITHUB_REPOSITORY mattgodbolt/seasocks
    GIT_TAG v1.4.6
    OPTIONS "UNITTESTS OFF" "SEASOCKS_EXAMPLE_APP OFF")
target_compile_features(my_server PRIVATE cxx_std_17)
target_link_libraries(my_server PRIVATE Seasocks::seasocks)

Seasocks is built as a static library unless you set SEASOCKS_SHARED=ON (or BUILD_SHARED_LIBS=ON). Deflate support is on by default and requires zlib; configure with -DDEFLATE_SUPPORT=OFF to build without it. Projects linking a static, deflate-enabled install need zlib to be findable too.

관련 프로젝트 살펴보기

불러오는 중…