Difference between revisions of "enet.host:connect"

(Created page with "Connects a host to a remote host. Returns peer object associated with remote host. The actual connection will not ...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
Connects a [[enet.host | host]] to a remote [[enet.host | host]]. Returns [[enet.peer | peer]] object associated with remote [[enet.host | host]]. The actual connection will not take place until the next [[enet.host:service | host:service()]] is done, in which a "connect" [[enet.event | event]] will be generated.
+
Connects a [[enet.host | host]] to a remote [[enet.host | host]]. Returns [[enet.peer | peer]] object associated with the remote [[enet.host | host]]. The actual connection will not take place until the next [[enet.host:service | host:service()]] is called, in which a "connect" [[enet.event | event]] will be generated.
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
event = host:service( timeout )
+
peer = host:connect(address, channel_count, data)
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|number|timeout|The max number of milliseconds to be waited for an [[enet.event | event]]. Default is 0.}}
+
{{param|string|address|The address to connect to in the format "ip:port".}}
 +
{{param|number|channel_count|The number of channels to allocate. It should be the same as the channel count on the server. Defaults to 1.}}
 +
{{param|number|data|An integer value that can be associated with the connect [[enet.event | event]]. Defaults to 0.}}
 
=== Returns ===
 
=== Returns ===
{{param|table|event|An [[enet.event | event]] or nil if no events occured.}}
+
{{param|enet.peer|peer|A [[enet.peer | peer]].}}
  
 
== See Also ==
 
== See Also ==

Latest revision as of 17:16, 9 October 2014

Connects a host to a remote host. Returns peer object associated with the remote host. The actual connection will not take place until the next host:service() is called, in which a "connect" event will be generated.

Function

Synopsis

peer = host:connect(address, channel_count, data)

Arguments

string address
The address to connect to in the format "ip:port".
number channel_count
The number of channels to allocate. It should be the same as the channel count on the server. Defaults to 1.
number data
An integer value that can be associated with the connect event. Defaults to 0.

Returns

enet.peer peer
A peer.

See Also

Other Languages