Difference between revisions of "enet.host create"

m (Synopsis: This isn't a global...)
m (Added note about port 0)
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
A bind_address of [[nil]] makes a [[enet.host | host]] that can not be connected to (typically a client). Otherwise the address can either be of the form <ipaddress>:<port>, <hostname>:<port>, or *:<port>.
 
A bind_address of [[nil]] makes a [[enet.host | host]] that can not be connected to (typically a client). Otherwise the address can either be of the form <ipaddress>:<port>, <hostname>:<port>, or *:<port>.
  
Example addresses include "127.0.0.1:8888", "localhost:2232", and "*:6767".
+
Example addresses include "127.0.0.1:8888", "localhost:2232", and "*:6767". If port is 0, the system automatically chooses an ephemeral port and you can get port number by [[enet.host:get_socket_address|host:get_socket_address]]().
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 13: Line 13:
 
{{param|string|bind_address|The address to connect to in the format "ip:port".}}
 
{{param|string|bind_address|The address to connect to in the format "ip:port".}}
 
{{param|number|peer_count|The max number of peers. Defaults to 64.}}
 
{{param|number|peer_count|The max number of peers. Defaults to 64.}}
 +
{{param|number|channel_count|The max number of channels. Defaults to 1.}}
 
{{param|number|in_bandwidth|Downstream bandwidth in bytes/sec. Defaults to 0 (unlimited).}}
 
{{param|number|in_bandwidth|Downstream bandwidth in bytes/sec. Defaults to 0 (unlimited).}}
{{param|number|channel_count|The max number of channels. Defaults to 1.}}
 
 
{{param|number|out_bandwidth|Upstream bandwidth in bytes/sec. Defaults to 0 (unlimited).}}
 
{{param|number|out_bandwidth|Upstream bandwidth in bytes/sec. Defaults to 0 (unlimited).}}
 
=== Returns ===
 
=== Returns ===
 
{{param|enet.host|host|The requested [[enet.host | host]].}}
 
{{param|enet.host|host|The requested [[enet.host | host]].}}
 
 
== See Also ==
 
== See Also ==
 
* [[parent::lua-enet]]
 
* [[parent::lua-enet]]
Line 25: Line 24:
 
* [[enet.host:bandwidth_limit]]
 
* [[enet.host:bandwidth_limit]]
 
== Other Languages ==
 
== Other Languages ==
{{i18n|enet:host_create}}
+
{{i18n|enet.host_create}}

Latest revision as of 17:11, 9 May 2019

Returns a new host. All arguments are optional.

A bind_address of nil makes a host that can not be connected to (typically a client). Otherwise the address can either be of the form <ipaddress>:<port>, <hostname>:<port>, or *:<port>.

Example addresses include "127.0.0.1:8888", "localhost:2232", and "*:6767". If port is 0, the system automatically chooses an ephemeral port and you can get port number by host:get_socket_address().

Function

Synopsis

host = enet.host_create(bind_address, peer_count, channel_count, in_bandwidth, out_bandwidth)

Arguments

string bind_address
The address to connect to in the format "ip:port".
number peer_count
The max number of peers. Defaults to 64.
number channel_count
The max number of channels. Defaults to 1.
number in_bandwidth
Downstream bandwidth in bytes/sec. Defaults to 0 (unlimited).
number out_bandwidth
Upstream bandwidth in bytes/sec. Defaults to 0 (unlimited).

Returns

enet.host host
The requested host.

See Also

Other Languages