This SYNC AcceptNextConnection method returns the client socket handle this way :
clientSocket = CkSocket_AcceptNextConnection(listenSocket,0);
How to obtain the same result with the ASYNC method ?
task = CkSocket_AcceptNextConnectionAsync(listenSocket,0);
The following "CkTask_resultType(task);" return "object"
i.e. how to get the handle of an object just having the task ?
There's no problem with boolean (CkTask GetResultBool), integer CkTask GetResultInt), string results... but with an objet ?
asked May 04 at 13:09
Each type of Chilkat object that can possibly be the return value of a synchronous method call will have a method named LoadTaskResult.
For example, when AcceptNextConnection is called synchronously,it would return a Socket object. When called asynchronously it returns a Task object. When the task completes, the task object (internally) has a reference to the returned Socket object.
To get the returned object (such as the Socket object), your app creates a new instance of the object and then calls LoadTaskResult. For example, in C:
HCkSocket socket = CkSocket_Create(); success = CkSocket_LoadTaskResult(socket,task)Now you have a socket object that's been loaded with the socket object returned asynchronously in the background thread. (Actually, it's not "loaded" but the HCkSocket just references the internal socket object. The internal implementation objects are reference counted, and therefore the Task object is simply keeping a reference to the returned internal object. The LoadTaskResult method does the following: the caller discards his existing reference to the internal implementation object, and adds a reference to the implementation object held by the task.)