Skip to content

enoreex/ice_net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

261 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

ice_net c++

My convoluted implementation of a reliable protocol. If this is to be used, it should be used at most in a local network. Unfortunately, the library is not ready for multithreading yet.

About

The library now has:

  • Installation and support connections (RUDP functionality) - !!ITS NOT TCP!!
  • Handle/Send reliable packets (RUDP functionality) - !!ITS NOT TCP!!
  • Convenient logging system
  • The library is cross-platform

CMake (.a) or (.lib) or (.dll) or (.aar):

You may have noticed that library included folders with an ending (.a) (.lib), (.dll), (.aar).. You can also use it in C#, but it little uncomfortable, so to make it easier, I created a wrap for C#, so you don’t have to work with the (.dll) and (.aar) directly!

What to take:

(Windows C++) (.lib) (.dll)
(Windows C#)    (.dll)   
(Android C#)       (.aar)
(Unity C#)    (.dll) (.aar)
(Linux C++) (.a)   

(.a):

  • Everything I've added to the library is available to you.
  • You have full control over the server and client fields
  • (.a) libraries are very easy to use. (Only Linux)
  • Build with CMake: you need C++ compiler and Linux or Visual Studio!

(.lib):

  • Everything I've added to the library is available to you.
  • You have full control over the server and client fields
  • (.lib) libraries are very easy to use. (Only Windows)
  • Build with CMake: you need C++ compiler and Windows!

(.dll):

  • A separate file (ice_net.h) describes the methods you can use. Obviously, the flexibility of (.dll) is less than that of (.lib).
  • The (.dll) can be used even in C#, and EVEN in Unity. (Only Windows)
  • Build with CMake: you need C++ compiler and Windows!

(.aar):

  • A separate file (ice_net.h) describes the methods you can use. Obviously, the flexibility of (.aar) is less than that of (.lib).
  • The (.aar) can be used even in C#, and EVEN in Unity. (Only Android)
  • Build with CMake: you need C++ compiler and Android NDK!

Example

Common:

ice_logger::log_listener = [](std::string& s) { printf(s.c_str()); };
ice_logger::log_error_listener = [](std::string& s) { printf(("\033[31m" + s + "\033[0m").c_str()); };

Server:

rudp_server* sock = new rudp_server;
sock->socket = new udp_sock;
sock->socket->start(end_point(0, 8080));

sock->try_start();

sock->connection_added_callback = [&](rudp_connection* c) 
{ 
  ice_data::write data;
  data.add_string("Hello!");
  end_point ep = sock->connection_internal_get_remote_ep(c);
  sock->send_reliable(ep, data);
};

while (true) sock->update();

Client:

rudp_client* sock = new rudp_client;
sock->socket = new udp_sock;
sock->socket->start(end_point(0, 0));

sock->connect(end_point("127.0.0.1", 8080));

sock->external_data_callback = [](ice_data::read& d)
{
  std::cout << d.get_string() << std::endl;
};

while (true) sock->update();

Unity

If you work in Unity, I recommend you to use (.aar) and (.dll) at the same time (for correct operation they must be in Assets/Plugins). To work with C# and C++, use P/Invoke, or just download my wrap for unity, in which I did this work.

About

Simple library for reliable packet transmission over UDP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors