Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ENetConnection

Inherits: RefCounted < Object

A wrapper class for an ENetHost.

Description

ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).

Tutorials

Methods

void

bandwidth_limit ( int in_bandwidth=0, int out_bandwidth=0 )

void

broadcast ( int channel, PackedByteArray packet, int flags )

void

channel_limit ( int limit )

void

compress ( CompressionMode mode )

ENetPacketPeer

connect_to_host ( String address, int port, int channels=0, int data=0 )

Error

create_host ( int max_peers=32, int max_channels=0, int in_bandwidth=0, int out_bandwidth=0 )

Error

create_host_bound ( String bind_address, int bind_port, int max_peers=32, int max_channels=0, int in_bandwidth=0, int out_bandwidth=0 )

void

destroy ( )

Error

dtls_client_setup ( String hostname, TLSOptions client_options=null )

Error

dtls_server_setup ( TLSOptions server_options )

void

flush ( )

int

get_local_port ( ) const

int

get_max_channels ( ) const

ENetPacketPeer[]

get_peers ( )

float

pop_statistic ( HostStatistic statistic )

void

refuse_new_connections ( bool refuse )

Array

service ( int timeout=0 )

void

socket_send ( String destination_address, int destination_port, PackedByteArray packet )


Enumerations

enum CompressionMode:

CompressionMode COMPRESS_NONE = 0

No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.

CompressionMode COMPRESS_RANGE_CODER = 1

ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.

CompressionMode COMPRESS_FASTLZ = 2

FastLZ compression. This option uses less CPU resources compared to COMPRESS_ZLIB, at the expense of using more bandwidth.

CompressionMode COMPRESS_ZLIB = 3

Zlib compression. This option uses less bandwidth compared to COMPRESS_FASTLZ, at the expense of using more CPU resources.

CompressionMode COMPRESS_ZSTD = 4

Zstandard compression. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases.


enum EventType:

EventType EVENT_ERROR = -1

An error occurred during service. You will likely need to