|
Start a server.
The transport associated with the listenAddr 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 server. 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 server. The server's lifetime terminates when the Transport Handler is notified via its Stopped method.
This callback may be NULL if the transport does not support servers.
- Parameters
-
transport | The Transport. This parameter must not be NULL. |
config | Transport defined configuration options for relatedServer. If NULL, default options will be used. |
listenAddress | The address the server should bind to, which may be an address that indicates all known addresses for the transport should be bound. It may alternatively represent a multicast or broadcast address, in which case the server must prepare to accept such traffic (e.g., join a multicast group). This must not be NULL. |
handler | The associated transport handler for the server. Once the server is started successfully, the Started method of handler must be called with the server object that represents the server created by this call. If the server cannot be opened successfully, Stopped must be called with the appropriate exception. Even if this call may determine synchronously that the server is successful or failed, a valid DTLServer 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 server to start, either DOFSERVERTYPE_STREAM or DOFSERVERTYPE_DATAGRAM. |
relatedServer | An existing, related server, if any. Some datagram servers may want to utilize or reference the configuration or implementation of an existing server. For example, a UDP multicast server may simply join the multicast group on the existing server's socket, instead of creating a new, separate socket. If a server is shared, however, it is the transport's responsibility to correctly identify to which server a packet belongs. |
context | The context for this server. This context must be associated with the server object that represents this server, when passed to the handler. |
- 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 DTLServer itself. All other errors must result in TRUE returned and the handler's Stopped method called with the appropriate exception (as described above). |
|