Code Monkey home page Code Monkey logo

enet-csharp's People

Contributors

katori avatar softwareguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enet-csharp's Issues

Question about Unity Input and ENet Thread Safety

ENet is said to generally be not thread safe. So how would you do peer.Send(...) outside of the thread worker? For example, lets say I want to send a packet when someone presses the R key with Input.GetKeyDown(KeyCode.R) in Unity's void Update() loop. This could only be possible if Peer peer was defined outside the scope of the thread worker.

Please refer to the issue linked below for more details.

Raccoons-Rise-Up/client-unity#1

Sent 3 bytes from client to server (server says 4 bytes were received)

Issue

I sent a byte and ushort from the client to the server (should be a total of 3 bytes) (byte is 1 byte) (ushort is 2 bytes)

https://github.com/Kittens-Rise-Up/client/blob/abaf999f1184200edd97b4431f4757f9287805d1/Assets/Scripts/Netcode/ENetClient.cs#L147-L150

The server read the receiving packet as a total of 4 bytes. (I was expecting to see 3)

The m_ID (byte opcode) was correct but the m_ItemID (ushort) read a 1 when it should have been a 0.

https://github.com/Kittens-Rise-Up/server/blob/2f1d8627d3d32aab9652281882c509dc736930c3/src/Program.cs#L78-L79

Steps to Reproduce

Run the dotnet server found here.

Run the Unity client found here (Run the game and click the "Connect" button bottom left then when connected to the server, press R to send the PurchaseItem data to the server)

Auto reconnect

Hi,
Is the library able to reconnect when disconnected?
I couldn't find this option.

Do you only call ENet.Library.Initialize() once?

I have setup a game where the client and server are shipped together.

What I'm doing right now

I call ENet.Library.Initialize(); and ENet.Library.Deinitialize(); for each client and server I create.

In my game there are sometimes more than one client (dummy clients) that are created and call ENet.Library.Initialize(); for each dummy client. And finally call ENet.Library.Deinitialize();

I know for sure that a game can have a client and server running at the same time meaning ENet.Library.Initialize(); gets called twice before ENet.Library.Deinitialize(); gets called.

Should I be doing this instead?

Should I only initialize and deinitialize ENet once in some static class? Init on game startup, deinit on game exit.

Just asking because maybe there is some weird thread design rule I need to follow? Sorry if this is a dumb question.

Errors on Build / Export Godot Project

image

This error happens when I try to build / export my Godot project.

I found this error on the web that was similar to mine https://godotengine.org/qa/85919/godot-mono-export-cannot-load-assembly-refonly-xamarin-please except theirs had something to do with iOS related.

I've never had this issue when building / exporting on main branch, this only started happening when I decided to start all over on dev branch. Repo: https://github.com/Raccoons-Rise-Up/client-godot

Steps to Reproduce
Clone dev branch from https://github.com/Raccoons-Rise-Up/client-godot and export project. Errors should appear on project export.

.csproj
image

NuGet packages viewed in Visual Studio Community
image

Included ENet files
image

I'm running on Windows 10 64 bit.

Is it normal to have a ~1 second delay between each client connection to the server?

2023-03-23.20-32-37.mp4

Above you can see it takes about 50 seconds for 50 clients to connect. During this time all the position packets are not sent because the connections are freezing up the server.

The delay between client connections is undesired, it would be nice if they all connected at the same time. I'm assuming these connection delays freeze up the server which would cause unwanted lag spikes in gameplay when someone joins the server.

Is there anyway to fix this? Am I doing something wrong?

Source can be found here: https://github.com/Valks-Games/Multiplayer-Template

What are the differences?

from the README:

an independent ENet native implementation with a modified protocol

What does "modified" mean in this sentence?

Does it mean that this library is not compatible with the original enet at http://enet.bespin.org? that the protocol used here is different?

Problems when sending reliable packets on high frequency

First I want to say thanks for this amazing library. I really enjoy using it but I'd like to share my findings and possibly get a confirmation from your end. I've started using the ENet-CSharp implementation from nxrighthere, and made my own library on top of it. I noticed that after some (random) amount of time the server would stop receiving packets from one or more clients. I initially thought I created a bug somewhere, and since my library was pretty wild and I found it hard to track down the issue, I decided to create a new one. So far so good, I had everything laid out nicely and it was much easier to use and maintain.

Then I noticed I got the same problem as I had before. After some random amount of time the server stopped receiving packets from one or more clients. The server would still see these clients as connected, and it happily kept sending packets (with old data) to everyone including the client who could not get his packets delivered anymore. These 'zombie' clients also kept receiving packets, they were just unable to get their packets delivered to the server. I've done a lot of logging to find the issue but I just could not find any logical explanation to the cause. I considered that maybe there's a bug in nxrigthere's library, so I tried yours with good hope it might not have this problem. Turned out I was wrong. I had the same problem and I started to realize it possibly isn't a bug, but just something I'm not fully understanding.

Long story short, I was thinking about the numbers of sent/received packets on the clients, and made the observation that the number of sent packets was consistently higher than the number of received. I then thought maybe it has something to do with the fact that I am sending reliable packets on a high frequency and on failure of delivery, they have to be resent, which possibly could cause a backlog of packets until everything crumbles. So I tested to mark these packets as unreliable, and behold, the issue seemed to be gone. The number of sent packets is now also consistently lower than the number of received. I realize now what I did was probably not the smartest thing to do, but I didn't expect it to be so problematic.

My question for you: do you think sending reliable packets on a high frequency (lets say 10 packets per second) could lead to the issue I described? If not, why not and how else should one deal with this? If yes, are you willing to add this issue to the 'common mistakes during integration'? I have done a lot of digging but couldn't find any specific information regarding all this, and it might be useful for others to consider.

SIGSEGV On Linux (Manjaro - Archlinux)

Hi, I am trying to use this ENet implementation into the Godot Engine, however I get a crash on linux system (manjaro - archlinux), work well on the windows build.
The same crash also happens using the "classic" ENet-CSharp package.
Here is the crash :

=================================================================
	Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================
	0xb8e86b - ./p2p.x86_64 : 
	0xb8ebf9 - ./p2p.x86_64 : 
	0xb818bf - ./p2p.x86_64 : 
	0xaf9069 - ./p2p.x86_64 : 
	0x24c6b60 - ./p2p.x86_64 : enet_peer_reset_queues
	0x7f526497033a - /media/linux/libenet.so : enet_host_create
	0x41961a98 - Unknown

=================================================================
	Telemetry Dumper:
=================================================================
Pkilling 0x139991845959232x from 0x139992361540992x
Could not exec mono-hang-watchdog, expected on path '/media/linux/data_enet-p2p/Mono/etc/../bin/mono-hang-watchdog' (errno 2)
Entering thread summarizer pause from 0x139992361540992x
Finished thread summarizer pause from 0x139992361540992x.
Failed to create breadcrumb file (null)/crash_hash_0x3ce389cc2

Waiting for dumping threads to resume

I use the libenet.so from the release, and ENetCsharp.dll has been compiled by me targetting .NET 4.7.2

LAN Peer Discovery

Hello, I've managed to implement game hosting and joining in Unity and it works great!

An issue I currently have is the method one should use to connect to a host. Currently, the user has to type the IP and then connect, which is not exactly ideal as the game is meant to run on Android phones that support Google Cardboard.

One method I found is by using Address.SetHost("255.255.255.255") which works fine, but I would like to be able to find multiple hosts on a single LAN Network and then choose which one I would like to connect to. How would something like this be done?

Release for x86 platform

Hello, friend! Thanks a lot for your great work. I want to use it in my project, But I need your help here.
My project has to have x86 architecture but x64 version provided here only. And the package from nuget seems to x64 also.
I've tried to build x86 myself but I've managed to produce enet.dll and enet.lib and no I idea what to do next. I mean how to use it in my C# project. I've tried to added enet.dll through Reference in my project I got the error: 'enet.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
Will you be so kind to overcome the situation? Thanks a lot in advance.

I've managed to produce ENet-CSharp.dll. The projects compiles but when run I got "Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified." What can be the reason? Thanks in advance.

C# Server with C++ Client

Hi,

I am trying to get ENet working with a C# server and a C++ client.

My issue is that the client says the connection was successful, however the server's EventType.Connect event is never called.

Is there any known issues with this?

Thanks.

NSLog instead of printf for iOS

Thanks for fixing the logging issue on iOS with #15 task.

You are currently using printf for logging but it is only available while debugging.

If you could use NSLog then it will be possible to check logs even from TestFlight releases.

I don't know much about how building native code works.

Is it possible to use NSLog for iOS build maybe even for MacOS builds?

Thanks.

Does enet merge small packets before sending?

If I send 100 packets in a single frame is enet going to then send 100 packets over the wire or does it combine packets and send only sometimes? I am using service with the timeout set to 0 btw.

How to tell if client was disconnected because they exceeded max peers set on server?

If I create a server with a max of 5 peers.

var maxPeers = 5;
server.Create(new Address { Port = port }, maxPeers);

And 6 peers try to join. The 5 peers will get in but the 6th peer will timeout. How can I inform the 6th peer that they could not enter the server because they exceeded the maximum peer limit instead of just saying "Your connection to the server timed out" implying that the server could be offline.

Unable to use the .so file

Hi,
The library from nxrighthere didn't work for me so I tried to use yours. I tried to build the .so library but I cannot wrap my head around of how to use it with RiderC#. Adding a reference seemed not to work because Rider doesn't find the file.

Maybe you have an idea, my problem appeared after a couple thousands of packets were sent between clients and the server and at a random moment in time, my program crashed and "free(): invalid pointer Aborted (core dumped)" showed up. Maybe you have an idea...

Thank you for your time :)

Trying to get working on MacOS

I have someone who is trying to contribute to my project but their running a Mac and they can't seem to get enet working. They say they have an error / the game simply won't build.

The project has these 2 enet files. They work for me on Windows 10.

image

I told them to try and put the enet.bundle file found from the releases in this repo next to the project files but they got the same error.

I also told them to try putting the files found from the releases in https://github.com/nxrighthere/ENet-CSharp/releases but that did not work either and they still get same error on startup.

I will update this issue once they tell me what the actual error message is that they get.

n/a

No longer needed.

UWP Support?

Did not know where to ask so I ask here.
I'd like to use Dissonance across the board but UWP is missing and so I'm stuck with Telepathy, which is not the brightest idea.
I was told by Dissonancees that I should use Ignorance for UDP transport, which is using ENET under the hood. Would it be hard to port it to UWP?
With Hololens 2 in the making it would be great to have it for x32 (HL1), x64(desktop) and ARM64 (HL2)

C# ENet client vs C++ ENet server

Hello!
I want to move my game from native TCP to ENet UDP. I have a C++ ENet game server and a Unity game.
I ran into an incomprehensible problem using your version of C# ENet.
I started the server and try to connect to it from the Unity through your ENet library, but the connection fails. In a Unity, when try connecting, it displays a connection timeout error. The server does not respond in any way to connection attempts.
I created an ENet client in C++ - it connects to my game server without problems and works.
Have you ever faced a similar task - connect from C# ENet client to a C++ ENet server?
I saw a post about a C++ ENet client and a C# ENet server, but there was a reaction to the connection, but I have not observed any reaction.
What could be the problem?
All code is used from the documentation - I did not add anything extra.

Troubles with Building Library

I run the following commands to start the build.

dotnet clean
dotnet build -c Release

And I get the following errors / warnings output in console. What's going on here?

  CMake -- configuring Debug AnyCPU: enet
  CMake -- cmake -G"Visual Studio 16 2019" -Tv142   -DENET_DEBUG=ON C:\Users\valkyrienyanko\Desktop\ENet-CSharp\
  CMake Error at CMakeLists.txt:25 (project):
    Generator

      Visual Studio 16 2019

    could not find any instance of Visual Studio.



C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(97,9): error MSB3073: The command "cmake -G"Visual Studio 16 2019" -Tv142   -DENET_DEBUG=ON C:\Users\valkyrienyanko\Desktop\ENet-CSharp\" exited with code 1. [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(120,9): warning : CMake -- the most common cause of CMake build errors is changing config without cleaning [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(121,9): warning : CMake -- please try cleaning and building again before filing an issue on github: [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(122,9): warning : CMake -- https://github.com/SoftwareGuy/ENet-CSharp [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(123,9): error : CMake -- build failed: enet [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]

Build FAILED.

C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(120,9): warning : CMake -- the most common cause of CMake build errors is changing config without cleaning [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(121,9): warning : CMake -- please try cleaning and building again before filing an issue on github: [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(122,9): warning : CMake -- https://github.com/SoftwareGuy/ENet-CSharp [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(97,9): error MSB3073: The command "cmake -G"Visual Studio 16 2019" -Tv142   -DENET_DEBUG=ON C:\Users\valkyrienyanko\Desktop\ENet-CSharp\" exited with code 1. [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.Build.targets(123,9): error : CMake -- build failed: enet [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
    3 Warning(s)
    2 Error(s)

Time Elapsed 00:00:03.33

Update

I opened the .sln file in Visual Studio, then closed the project and tried building the project again with clean and build and got the following errors in console.

C:\Users\valkyrienyanko\Desktop\ENet-CSharp>dotnet build
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 51.74 ms for C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\ENetTests\ENetTests.csproj.
  Restore completed in 51.72 ms for C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj.
  Restore completed in 51.72 ms for C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\ENetCSharp\ENetCSharp.csproj.
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(16,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(17,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(18,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(19,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(13,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(14,61): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(15,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(16,68): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(17,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(18,53): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(19,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(10,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(11,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]

Build FAILED.

obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(16,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(17,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(18,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(19,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(13,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(14,61): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(15,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(16,68): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(17,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(18,53): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(19,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(10,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
obj\Debug\netcoreapp2.2\CMake.AssemblyInfo.cs(11,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\valkyrienyanko\Desktop\ENet-CSharp\MSBuild\CMake\CMake.csproj]
    0 Warning(s)
    16 Error(s)

Time Elapsed 00:00:01.11

Host creation call failed

Hello, I am using the default template code provided from the README.md yet I get this error on startup.

This is being done in a brand new dotnet console app. I used nuget to get the latest ENet-CSharp version.

image

All code can be seen below

using System;
using ENet;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
			ENet.Library.Initialize();

			int maxClients = 100;
			ushort port = 8888;
			using (Host server = new Host())
			{
				Address address = new Address();

				address.Port = port;
				server.Create(address, maxClients);

				Event netEvent;

				while (!Console.KeyAvailable)
				{
					bool polled = false;

					while (!polled)
					{
						if (server.CheckEvents(out netEvent) <= 0)
						{
							if (server.Service(15, out netEvent) <= 0)
								break;

							polled = true;
						}

						switch (netEvent.Type)
						{
							case EventType.None:
								break;

							case EventType.Connect:
								Console.WriteLine("Client connected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
								break;

							case EventType.Disconnect:
								Console.WriteLine("Client disconnected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
								break;

							case EventType.Timeout:
								Console.WriteLine("Client timeout - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
								break;

							case EventType.Receive:
								Console.WriteLine("Packet received from - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP + ", Channel ID: " + netEvent.ChannelID + ", Data length: " + netEvent.Packet.Length);
								netEvent.Packet.Dispose();
								break;
						}
					}
				}

				server.Flush();
			}

			ENet.Library.Deinitialize();
		}
    }
}

CI and Binary Releases

Is it possible to configure CI with Github Actions and release binaries for this repo?

Currently I'm using the binaries from Ignorance but I think they should be released from this repo.

Unity build?

Hi, I didn't see any issues about this, so figured I would ask. The nxrighthere repo has a separate build for Unity. Is there supposed to be a build artifact for Unity projects on here, or what's the difference when building for Unity?

Can you provide the x86 version of the pre-built library?

Due to some legacy reasons, our program has to run on x86, but the pre-built library does not include the x86 version. Is it possible to provide them?

Of course, on windows I can use cmake to generate x86 and x64 configurations to solve this problem, but we still need to support linux at least, but I am not an expert in this area, if any help information is available, it would be greatly appreciated.

thanks

Having Troubles Understanding the Parameters for Peer.Timeout(...)

My Question

What is the difference between timeoutLimit, timeoutMinimum and timeoutMaximum?

I put the defenition below for reference.

Peer.Timeout(uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum)

Peer.Timeout(uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum) sets a timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values used in the semi-linear mechanism, where if a reliable packet is not acknowledged within an average round-trip time plus a variance tolerance until timeout reaches a set limit. If the timeout is thus at this limit and reliable packets have been sent but not acknowledged within a certain minimum time period, the peer will be disconnected. Alternatively, if reliable packets have been sent but not acknowledged for a certain maximum time period, the peer will be disconnected regardless of the current timeout limit value.

ENet Timeout Event Does not Appear to be Firing Server-Side

Steps to Reproduce

  1. Run web server (required or you'll have to comment out some code client side that handles logging into the web server)
  2. Run game server
  3. Run client
  4. Log in through client to game server
  5. Close client
  6. Notice how timeout event does not fire server-side

Where would you even define the timeout for the peer (client)? (Doing netEvent.Peer.Timeout(1000, 1000, 1000); server-side when the peer connects does not seem to do anything)

ENet.Packet.Create(IntPtr,...) not accepting IntPtr.Zero

I was just reading through the code and maybe found one inconsistency.

The Managed wrapper of ENet.Packet.Create(IntPtr, ...) is not accepting a IntPtr.Zero as a first parameter. It will throw an exception.

public void Create(IntPtr data, int length, PacketFlags flags)
{
  // I would suggest to remove this exception.
  if (data == IntPtr.Zero)
    throw new ArgumentNullException("data");

  // This check seems to be still important.
  if (length < 0)
    throw new ArgumentOutOfRangeException("length");
  nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
}

When comparing the native interface, IntPtr.Zero looks like a valid option. According to my understanding, it will simply reserve the requested memory, WITHOUT actually copy provided data. This way the user could manually write to the buffer, by requesting:

var myPointer = ENet.Packet.Data;
// Possibly use code like this to write to the buffer.
System.Runtime.InteropServices.Marshal.WriteInt32(myPointer, 0, 4);
// Or use unsafe code like:
int* pBuffer = (int*)myPointer.ToPointer();
*pBuffer = 11;

I am using this approach to 'serialize' a structure directly to the network buffer. This way, I do not have to serialize the data into a byte array, before copy it a second time to the native buffer. That should prevent unneccessary allocations.

Here is the relevant native code:

ENetPacket* enet_packet_create(const void* data, size_t dataLength, uint32_t flags) 
{
  ENetPacket* packet;
  
  if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) {
	  packet = (ENetPacket*)enet_malloc(sizeof(ENetPacket));
  
	  if (packet == NULL)
		  return NULL;
  
	  packet->data = (uint8_t*)data;
  } else {
	  packet = (ENetPacket*)enet_malloc(sizeof(ENetPacket) + dataLength);
  
	  if (packet == NULL)
		  return NULL;
  
	  packet->data = (uint8_t*)packet + sizeof(ENetPacket);
  
          // ***********************
          // This is the relevant part:
          // "data" NULL is valid, it will only prevent a copy operation. It look like this is an intended feature.
          // ***********************
	  if (data != NULL) 
		  memcpy(packet->data, data, dataLength);
  }
    
  packet->referenceCount = 0;
  packet->flags = flags;
  packet->dataLength = dataLength;
  packet->freeCallback = NULL;
  packet->userData = NULL;

  return packet;
}

What do you think about it, or did I miss something relevant?

Kind regards
Pix

iOS Debugging - File Access Permission

Hello,

I'm trying to use the debug version of your library for iOS but it is trying to create a log file and write to that file.

But it is not possible as iOS application only has access to certain folders because of security.

Here is the log event I got from the device.
Sandbox: backgammon(400) deny(1) file-write-create /enet_log.txt

Could you guide me how to use the debug version for iOS?

P.S. Thanks for the the great work.

Issues with C++

Greetings!

I'm using the latest release of this repo in a C++ server and C# client,

With the C++ server, I'm including your enet.h file and I link your built libraries. (So no mix and matching versions.)

There is no address.host and enet_address_set_host() in the enet.h. You've said in several other threads that there is, but literally, there is no binding for it in your ENet.cs file or mention of it in enet.h. If you even search this repo here on github, you get a "We couldn't find any code matching 'enet_address_set_host' in SoftwareGuy/ENet-CSharp.

It would be nice to know a work around for this, since the official ENet tutorials and just about everything else on the net references:

ENetAddress address;
address.host = ENET_HOST_ANY; 
 enet_address_set_host(&address, "192.168.0.100"); 

If you try that with your header, you get address.host not found, ENET_HOST_ANY is ipv6 only? and enet_address_set_host not found.

If I look back at the repo from 2019, it's there. But it isn't in the most current ones.


As a work around, I do a enet_address_set_ip() or a enet_address_set_hostname(). But if you give these functions a ipv4 address, it only spits out an ipv6 of ffff0000...

Increasing degradation of packet delivery time

Hello, friend! Thanks again for your great work! I've started integration of enet-csharp into my project and have faced with the problem which are not able to resolve. I'm using the code from your quick start examples with small changes (server.Service(0, out netEvent)) and if the size of the packets is small (10kb for example) so everything goes well - the speed is high and stable. But when the size of packets is bigger (100kb for example) the speed is constantly decrease and the speed becomes unacceptable. I've read all available documents but not able to figure out what's wrong. Will you be so kind to help me with it? Thanks a lot in advance.

Client connection timeout

Issue

I am trying to connect Unity ENet-CSharp client to ENet-CSharp dotnet server. The problem is the client always times out when trying to connect to the server. "Client connection timeout" is logged to the console.

Steps to Reproduce

  1. Download my Unity client and open up project up through Unity Hub
  2. Setup a simple dotnet console app with default enet-csharp server code
  3. Run server
  4. Run client

Code

Client Code: https://github.com/Kittens-Rise-Up/client/blob/main/Assets/Scripts/ENetClient.cs

Server code is default template provided from the README.md from this repo SoftwareGuy/ENet-CSharp

Notes

My windows firewall is disabled.

Ports are the same on client and server.

I used Nuget to get ENet-CSharp for the dotnet server and I compiled ENet-CSharp from source (inside MSBuild folder) and placed ENet-CSharp.dll and enet.dll (found from MSBuild\ENetCSharp\bin\Debug\netstandard2.0) inside the Unity client. Maybe I am using 2 different versions of enet and that's why the client cannot connect to the server?

I have tried using my IPv4, my external IP and "127.0.0.1", all of them result in a client timeout.

I'm not sure why this is happening as I remember having no issues with this setup in the past.

Update

I was able to connect a dotnet client to a dotnet server with no issues even with my firewall enabled. However connecting the Unity client to the dotnet server does not work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.