All Projects → zpl-c → Enet

zpl-c / Enet

Licence: mit
⚡️ ENet reliable UDP networking library

Programming Languages

c
50402 projects - #5 most used programming language
cpp
1120 projects

Projects that are alternatives of or similar to Enet

Enet Csharp
Reliable UDP networking library
Stars: ✭ 464 (+129.7%)
Mutual labels:  gamedev, networking, udp, ipv6
Valvesockets Csharp
Managed C# abstraction of GameNetworkingSockets library by Valve Software
Stars: ✭ 273 (+35.15%)
Mutual labels:  gamedev, networking, udp, ipv6
Librg
🚀 Making multi-player gamedev simpler since 2017
Stars: ✭ 813 (+302.48%)
Mutual labels:  gamedev, lightweight, network, networking
Iptools
PHP Library for manipulating network addresses (IPv4 and IPv6)
Stars: ✭ 163 (-19.31%)
Mutual labels:  network, networking, ipv6
Litenetlib
Lite reliable UDP library for Mono and .NET
Stars: ✭ 2,179 (+978.71%)
Mutual labels:  network, networking, udp
Game Networking Resources
A Curated List of Game Network Programming Resources
Stars: ✭ 4,208 (+1983.17%)
Mutual labels:  gamedev, network, networking
Cnp3
Computer Networking : Principles, Protocols and Practice (first and second edition, third edition is being written on https://github.com/cnp3/ebook)
Stars: ✭ 471 (+133.17%)
Mutual labels:  networking, udp, ipv6
Hp Socket
High Performance TCP/UDP/HTTP Communication Component
Stars: ✭ 4,420 (+2088.12%)
Mutual labels:  network, networking, udp
Ineter
Fast Java library for working with IP addresses, ranges, and subnets
Stars: ✭ 39 (-80.69%)
Mutual labels:  network, networking, ipv6
Netdynamics
Data-oriented networking playground for the reliable UDP transports
Stars: ✭ 65 (-67.82%)
Mutual labels:  gamedev, networking, udp
Laminar
A simple semi-reliable UDP protocol for multiplayer games
Stars: ✭ 530 (+162.38%)
Mutual labels:  gamedev, networking, udp
Ruffles
Lightweight and fully managed reliable UDP library.
Stars: ✭ 131 (-35.15%)
Mutual labels:  network, networking, udp
Fi6s
IPv6 network scanner designed to be fast
Stars: ✭ 116 (-42.57%)
Mutual labels:  network, udp, ipv6
Netlink
Socket and Networking Library using msgpack.org[C++11]
Stars: ✭ 197 (-2.48%)
Mutual labels:  networking, udp, ipv6
Ignorance
Ignorance utilizes the power of ENet to provide a reliable UDP networking transport for Mirror Networking.
Stars: ✭ 158 (-21.78%)
Mutual labels:  networking, udp
Netstack
Lightweight toolset for creating concurrent networking systems for multiplayer games
Stars: ✭ 157 (-22.28%)
Mutual labels:  gamedev, networking
Go Ping
A simple ping library using ICMP echo requests.
Stars: ✭ 158 (-21.78%)
Mutual labels:  networking, ipv6
Ccna60d
60天通过思科认证的网络工程师考试
Stars: ✭ 155 (-23.27%)
Mutual labels:  network, networking
Mirror
#1 Open Source Unity Networking Library
Stars: ✭ 2,905 (+1338.12%)
Mutual labels:  networking, udp
Spitfire
An easy to use WebRTC Datachannels library for .NET applications.
Stars: ✭ 164 (-18.81%)
Mutual labels:  networking, udp
ENet

Build status Build status NPM version Discord server license

ENet - Simple, lightweight and reliable UDP networking library written on pure C
Brought to you by @lsalzman, @inlife, @zaklaus, @nxrighthere and other contributors!

Disclaimer

This is a fork of the original library lsalzman/enet. While original repo offers a stable, time-tested wonderful library, we are trying to change some things, things, which can't be reflected on the main repo, like:

  • integrated ipv6 support
  • added monotonic time
  • applied project-wide code style change
  • cleaned up project
  • single-header style code
  • NPM package distribution
  • removed a lot of older methods
  • and many other various changes

Description

ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol). The primary feature it provides is optional reliable, in-order delivery of packets, and fragmentation.

ENet omits certain higher level networking features such as authentication, lobbying, server discovery, encryption, or other similar tasks that are particularly application specific so that the library remains flexible, portable, and easily embeddable.

Installation (via npm)

Install library using (omit --save if you don't have npm project initilized)

$ npm install enet.c --save

Add include path to the library node_modules/enet.c/include to your makefile/

Installation (manually)

Dowload file include/enet.h and just add to your project.

Usage (Shared library)

Build the shared library:

$ mkdir build
$ cd build
$ cmake .. -DENET_SHARED=1 -DCMAKE_BUILD_TYPE=Release
$ cmake --build .

Use it:

#define ENET_DLL
#include <enet.h>
#include <stdio.h>

int main() {
    if (enet_initialize () != 0) {
        printf("An error occurred while initializing ENet.\n");
        return 1;
    }

    enet_deinitialize();
    return 0;
}

Usage (Static library)

Build the static library:

$ mkdir build
$ cd build
$ cmake .. -DENET_STATIC=1 -DCMAKE_BUILD_TYPE=Release
$ cmake --build .

Use it:

#include <enet.h>
#include <stdio.h>

int main() {
    if (enet_initialize () != 0) {
        printf("An error occurred while initializing ENet.\n");
        return 1;
    }

    enet_deinitialize();
    return 0;
}

Usage (Direct, Preferred)

In this case, library will be embedded to the project itself.

Make sure you add a define for ENET_IMPLEMENTATION exactly in one source file before including the enet.h.

Here is a simple server demo, it will wait 1 second for events, and then exit if none were found:

#define ENET_IMPLEMENTATION
#include <enet.h>
#include <stdio.h>

int main() {
    if (enet_initialize () != 0) {
        printf("An error occurred while initializing ENet.\n");
        return 1;
    }

    ENetAddress address = {0};

    address.host = ENET_HOST_ANY; /* Bind the server to the default localhost.     */
    address.port = 7777; /* Bind the server to port 7777. */

    #define MAX_CLIENTS 32

    /* create a server */
    ENetHost * server = enet_host_create(&address, MAX_CLIENTS, 2, 0, 0);

    if (server == NULL) {
        printf("An error occurred while trying to create an ENet server host.\n");
        return 1;
    }

    printf("Started a server...\n");

    ENetEvent event;

    /* Wait up to 1000 milliseconds for an event. (WARNING: blocking) */
    while (enet_host_service(server, &event, 1000) > 0) {
        switch (event.type) {
            case ENET_EVENT_TYPE_CONNECT:
                printf("A new client connected from %x:%u.\n",  event.peer->address.host, event.peer->address.port);
                /* Store any relevant client information here. */
                event.peer->data = "Client information";
                break;

            case ENET_EVENT_TYPE_RECEIVE:
                printf("A packet of length %lu containing %s was received from %s on channel %u.\n",
                        event.packet->dataLength,
                        event.packet->data,
                        event.peer->data,
                        event.channelID);
                /* Clean up the packet now that we're done using it. */
                enet_packet_destroy (event.packet);
                break;

            case ENET_EVENT_TYPE_DISCONNECT:
                printf("%s disconnected.\n", event.peer->data);
                /* Reset the peer's client information. */
                event.peer->data = NULL;
                break;

            case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
                printf("%s disconnected due to timeout.\n", event.peer->data);
                /* Reset the peer's client information. */
                event.peer->data = NULL;
                break;

            case ENET_EVENT_TYPE_NONE:
                break;
        }
    }

    enet_host_destroy(server);
    enet_deinitialize();
    return 0;
}

Tutorials

More information, examples and tutorials can be found at the official site: http://enet.bespin.org/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].