|
Open a connection.
The transport associated with the peer address must match the transport being called. This call should not block; if it does, the call may delay the caller longer than intended, and may result in the violation of certain expected timing constraints.
The parameters to this function are owned by the caller. However, they are maintained by the caller for the duration of the resulting connection. Therefore, there is no need for the transport to copy these parameters, so long as they are never used past the lifetime of the resulting connection. The connection's lifetime terminates when the Transport Handler is notified via its Closed method.
This callback may be NULL if the transport does not support connections.
- Parameters
-
transport | The Transport. This parameter must not be NULL. |
config | Transport-specific custom parameters for the connection. There are no standard parameters defined; the implementation is free to choose what options are valid, if any, and their appropriate behavior. If NULL, default parameters will be used. |
peer | The peer address representing the remote end of the connection. peer must not be NULL. |
handler | The associated transport handler for the connection. Once the connection is opened successfully, the Opened method of handler must be called with the connection object that represents the connection created by this call. If the connection cannot be opened successfully, Closed must be called with the appropriate exception. Even if this call may determine synchronously that the connection is successful or failed, a valid DTLConnection must be given to one of the handler methods to indicate the success or failure, and the same DTLServer (even if already freed, in the case of a failure) must be returned. handler must not be NULL. |
type | The type of connection to open, either DOFCONNECTIONTYPE_STREAM or DOFCONNECTIONTYPE_DATAGRAM. |
context | The context for this connection. This context must be associated with the connection object that represents this connection, when passed to the handler. The context is opaque to the connection. |
- Returns
- TRUE is returned. Success or failure is determined asynchronously via the handler callbacks as described above. It is possible that the callback is called prior to, concurrent with, or following the return of this function.
- Exceptions
-
FALSE | is returned to indicate an allocation failure of the DTLConnection itself. All other errors must result in TRUE returned and the handler's Closed method called with the appropriate exception (as described above). |
|