Portable, single-file, protocol-agnostic TCP and UDP socket wrapper, primarily for game networking

Overview

Documentation

This is a header-only library, as such most of its functional documentation is contained within the "header section" of the source code in the form of comments. It is highly recommended that you read said documentation before using this library.

Features

The swrap library provides a cross-platform socket wrapper with automatic protocol-agnosticity, its features include:

  • Encapsulates platform-specific socket implementations for both Windows and POSIX systems
  • Future-proof protocol-agnosticity thanks to the system-internal getaddrinfo function
  • Includes select and multi-select functions with timeouts in double seconds

Attribution

You are not required to give attribution when using this library. If you want to give attribution anyway, either link to this repository, my website, or credit me as BareRose. If you want to support me financially, consider giving to my Patreon.

License

Licensed under CC0 aka the most lawyer-friendly way of spelling "public domain".

Issues
  • ifndef'd TCP_NODELAY

    ifndef'd TCP_NODELAY

    Per our discussion, I thought I'd just push this thing because it's better to improve the code early and often than wait for the time when it's actually needed.

    opened by ghost 0
  • TCP_NODELAY undeclared with C++/Linux

    TCP_NODELAY undeclared with C++/Linux

    Compiling with g++ or clang++ on Ubuntu 18.04 results in the following error:

    include/swrap.h: In function ‘int swrapSocket(int, int, char, const char*, const char*)’:
    include/swrap.h:171:43: error: ‘TCP_NODELAY’ was not declared in this scope
                 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&nodelay, sizeof(nodelay));
    
    opened by ghost 0
  • Example or compile guide

    Example or compile guide

    It seems to me that this repository is no longer active. so I don't know if it would be interesting. Perhaps a compilation guide and a small example demonstrating how to use the interface could be placed

    opened by LucasGobbs 5
  • Strange interaction with standard headers in C99 mode with GCC

    Strange interaction with standard headers in C99 mode with GCC

    I was having trouble getting swrap to compile in C99 mode with GCC, but then I put

    #undef _DEFAULT_SOURCE
    #define _DEFAULT_SOURCE 1
    

    at the top of a .c file that #includes swrap.h and it worked. Sources: 1 2

    When something like stdio.h is included, it doesn't work by simply putting the snippet in or directly above the #include of swrap.h. You have to put the snippet above all includes in the translation unit to be safe.

    I have attached a test case. Try compiling it both ways. swrap_c_test.zip

    opened by ghost 3
Owner
Hobby game programmer, supporter of CC0 software and single-file libraries!
null
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Cesanta Software 8.5k Jun 29, 2022
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 848 Jun 26, 2022
Provide translation, currency conversion, and voting services. First using telnet you create a connection to a TCP socket, then the server connects to 3 UDP sockets hosted on other servers to do tasks.

to run micro servers g++ translator.cpp -o translator ./translator <port 1> g++ voting.cpp -o voting ./voting <port 2> g++ currency_converter.cpp -o c

Jacob Artuso 1 Oct 29, 2021
Winpcap-based network packet capture tool, support TLS (part), UDP, ICMP, TCP, ARP, DNS and other protocol analysis, interface reference wireshark.

Winpcap-based network packet capture tool, support TLS (part), UDP, ICMP, TCP, ARP, DNS and other protocol analysis, interface reference wireshark.

null 35 Jun 25, 2022
Socket and Networking Library using msgpack.org[C++11]

netLink C++ 11 KISS principle networking library. Features: C++ 11 IPv4, IPv6 Protocols: TCP, UDP Enable/Disable blocking mode Join/Leave UDP-Multicas

Alexander Meißner 208 May 29, 2022
Simple and small reliable UDP networking library for games

libquicknet Simple and small reliable UDP networking library for games ❗ libquicknet is under development and not suitable for production code ❗ The m

null 23 May 12, 2022
ENet reliable UDP networking library

Please visit the ENet homepage at http://enet.bespin.org for installation and usage instructions. If you obtained this package from github, the quick

Lee Salzman 2.1k Jul 3, 2022
Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption.

GameNetworkingSockets GameNetworkingSockets is a basic transport layer for games. The features are: Connection-oriented API (like TCP) ... but message

Valve Software 6.1k Jul 2, 2022
Data-oriented networking playground for the reliable UDP transports

NetDynamics is a data-oriented networking playground for the reliable UDP transports. The application was created for stress testing and debugging a p

Stanislav Denisov 88 Jun 20, 2022
Built a client-server application using TCP and UDP sockets, in which the clients can subscribe/unsubscribe to various topics.

Built a client-server application using TCP and UDP sockets, in which the clients can subscribe/unsubscribe to various topics.

null 1 Jun 22, 2022
Asynchronous, Header-only C++ HTTP-over-(TCP|UNIX Socket|STDIO) Library

CXXHTTP A C++ library implementing an asynchronous HTTP server and client. To clone this library, make sure you also clone the submodules. The --recur

null 25 Mar 19, 2021
Minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file

cz-spas czspas (Small Portable Asynchronous Sockets) is minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file.

Rui Figueira 25 Jun 12, 2022
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Qihoo 360 3k Jun 27, 2022
A TCP / UDP program supporting multiple test scenarios

sock_test A TCP / UDP program supporting multiple test scenarios The current communication protocol only supports UDP. TCP will be supported later. Ho

null 4 Mar 8, 2022
📡 TCP/UDP port redirector

rinetd, by Thomas Boutell and Sam Hocevar. Released under the terms of the GNU General Public License, version 2 or later. This program is used to eff

Sam Hocevar 420 Jun 28, 2022
Single file public domain networking library

zed_net zed_net is a single file, public domain library that provides a simple wrapper around BSD sockets (Winsock 2.2 on Windows), intended primary f

Ian T. Jacobsen 51 Jun 1, 2022
(Test assignment) Transfer files over the network using a homegrown UDP protocol

Требования Linux x86_64 gcc >= 4.9 (C++11) Сборка $ make Запуск $ make run -j5 -j5 позволяет серверу и четырём клиентам запуститься одновременно. В

Alexander Batischev 2 Dec 18, 2021
A protocol for secure client/server connections over UDP

netcode netcode is a simple connection based client/server protocol built on top of UDP. It has the following features: Encrypted and signed packets S

The Network Protocol Company 2.2k Jun 26, 2022
A protocol for secure client/server connections over UDP

netcode netcode is a simple connection based client/server protocol built on top of UDP. It has the following features: Encrypted and signed packets S

The Network Protocol Company 2.2k Jun 26, 2022