Use Godot as Client for Standlone ENet Sever coded in C++

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By yesLayla

So I have created a Standalone ENet server in C++, which seems to be working okay, but I am having issues sending data to it from Godot. When I run my client, it seems to be able to connect to the server without issue, but fails to send any data.

I’ve checked with Wireshark and there is no packets containing my test data.

My server code is just priting info about any ENet event.


My Client Code:

var network : NetworkedMultiplayerENet

func _ready():
    connect_to_network()

func connect_to_network():
    network = NetworkedMultiplayerENet.new()

```
print("Create client: " + str(network.create_client(SERVER_HOST, SERVER_PORT)))
get_tree().set_network_peer(network)

print("Send Packet: " + str(network.put_packet("TEST".to_ascii())))

print("Multiplayer Packet:" + str(get_tree().multiplayer.network_peer.put_packet("TEST2".to_ascii())))
```

My client output:

Create client: 0
Send Packet: 3
Multiplayer Packet:3

Server output:

Starting game server...
Started server console...
Awaiting connections...
Parsing event!
A new client connected from ______.
Parsing event!
(null) disconnected.

Things I’ve tried:

I’ve added

get_tree().multiplayer.network_peer = network

after creating the network, and it didn’t seem to have an effect.

I’ve ran

print("Send Packet: " + str(network.put_packet("TEST".to_ascii())))

print("Multiplayer Packet:" + str(get_tree().multiplayer.network_peer.put_packet("TEST2".to_ascii())))

on button press instead which changed output to

Send Packet: 0
Multiplayer Packet: 0

But I did not see any data in Wireshark

:bust_in_silhouette: Reply From: yesLayla

So I it looks like the Godot implementation of ENet is not a ENet library, but a multiplayer implementation that uses ENet.

I found this module that seems to work for my purposes.