![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
ENet - Simple, lightweight and reliable UDP networking library written on pure C.
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:
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.
Download file releases/latest/enet.h and just add to your project.
Build the shared library:
$ cmake -B build -DENET_SHARED=1 -DCMAKE_BUILD_TYPE=Release
$ cmake --build 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;
}
Build the static library:
$ cmake -B build -DENET_STATIC=1 -DCMAKE_BUILD_TYPE=Release
$ cmake --build 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;
}
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 and client demo, it will wait 1 second for events, and then exit if none were found:
Server:
#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;
}
Client:
#include <stdio.h>
#define ENET_IMPLEMENTATION
#include "enet.h"
int main() {
if (enet_initialize() != 0) {
fprintf(stderr, "An error occurred while initializing ENet.\n");
return EXIT_FAILURE;
}
ENetHost* client = { 0 };
client = enet_host_create(NULL /* create a client host */,
1 /* only allow 1 outgoing connection */,
2 /* allow up 2 channels to be used, 0 and 1 */,
0 /* assume any amount of incoming bandwidth */,
0 /* assume any amount of outgoing bandwidth */);
if (client == NULL) {
fprintf(stderr,
"An error occurred while trying to create an ENet client host.\n");
exit(EXIT_FAILURE);
}
ENetAddress address = { 0 };
ENetEvent event = { 0 };
ENetPeer* peer = { 0 };
/* Connect to some.server.net:1234. */
enet_address_set_host(&address, "127.0.0.1");
address.port = 7777;
/* Initiate the connection, allocating the two channels 0 and 1. */
peer = enet_host_connect(client, &address, 2, 0);
if (peer == NULL) {
fprintf(stderr,
"No available peers for initiating an ENet connection.\n");
exit(EXIT_FAILURE);
}
/* Wait up to 5 seconds for the connection attempt to succeed. */
if (enet_host_service(client, &event, 5000) > 0 &&
event.type == ENET_EVENT_TYPE_CONNECT) {
puts("Connection to some.server.net:1234 succeeded.");
} else {
/* Either the 5 seconds are up or a disconnect event was */
/* received. Reset the peer in the event the 5 seconds */
/* had run out without any significant event. */
enet_peer_reset(peer);
puts("Connection to some.server.net:1234 failed.");
}
// Receive some events
enet_host_service(client, &event, 5000);
// Disconnect
enet_peer_disconnect(peer, 0);
uint8_t disconnected = false;
/* Allow up to 3 seconds for the disconnect to succeed
* and drop any packets received packets.
*/
while (enet_host_service(client, &event, 3000) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_RECEIVE:
enet_packet_destroy(event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
puts("Disconnection succeeded.");
disconnected = true;
break;
}
}
// Drop connection, since disconnection didn't successed
if (!disconnected) {
enet_peer_reset(peer);
}
enet_host_destroy(client);
enet_deinitialize();
}
More information, examples and tutorials can be found at the official site: http://enet.bespin.org/
FAQs
ENet - Simple, lightweight and reliable UDP networking library written on pure C.
The npm package enet.c receives a total of 6 weekly downloads. As such, enet.c popularity was classified as not popular.
We found that enet.c demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.