ENet Class Library for C#

Host.Connect(String, Int32, Int32, Int32) Method

Connects to a remote computer at the given host and port.

[Visual Basic]
Public Overloads Sub Connect( _
   ByVal hostName As String, _
   ByVal port As Integer, _
   ByVal data As Integer, _
   Optional ByVal channelLimit As Integer = 0 _
public Peer Connect(
   string hostName,
   int port,
   int data,
   int channelLimit


The IP address or host name to connect to.
The port to connect to.
Data to send along with the connect packet.
The maximum number of channels, or 0 to use the maximum possible (255).

Return Value

The new peer. This method does not block: the connection will be established when you receive a Connect event.


Exception Type Condition
ArgumentNullException hostName is null.
ArgumentException hostName is invalid.
ArgumentOutOfRangeException hostName is too long, port is less than 0 or greater than 65535, and/or channelLimit is less than 0 or greater than 255.
InvalidOperationException The host is not initialized.
SocketException Host name lookup failed, or no IPv4 hosts were available.
ENetException An error occured.

See Also

Host Class | ENet Namespace | Host.Connect Overload List