Method Connect
Connect(int, NetworkEndpoint)
Establish a new connection to the given endpoint. Note that this only starts establishing the new connection. From there it will either succeeds (a Connect event will pop on the connection) or fail (a Disconnect event will pop on the connection) at a later time.
Declaration
public NetworkConnection Connect(int driverId, NetworkEndpoint endpoint)
Parameters
Type | Name | Description |
---|---|---|
int | driverId | ID of the driver to connect, as obtained with AddDriver(NetworkDriver). |
NetworkEndpoint | endpoint | Endpoint to connect to. |
Returns
Type | Description |
---|---|
NetworkConnection | New connection object, or a default-valued object on failure. |
Remarks
Establishing a new connection normally requires the driver to be bound (e.g. with the
Bind(NetworkEndpoint) method), but if that's not the case when calling this method, the
driver will be implicitly bound to the appropriate wildcard address. This is a behavior
similar to BSD sockets, where calling connect
automatically binds the socket to
an ephemeral port.