TPVSocketEvent OsclConnectMethod::Connect(OsclNetworkAddress& aAddress,
        int32 aTimeout)
{
    if (!StartMethod(aTimeout))
        return EPVSocketFailure;

    ConnectRequest()->Connect(aAddress);

    return EPVSocketPending;
}
TPVDNSEvent OsclGetHostByNameMethod::GetHostByName(char *name, OsclNetworkAddress *addr,
        int32 aTimeout, Oscl_Vector<OsclNetworkAddress, OsclMemAllocator> * aAddressList)
{
    if (!StartMethod(aTimeout))
        return EPVDNSFailure;

    iGetHostByNameRequest->GetHostByName(name, addr, aAddressList);

    return EPVDNSPending;
}
TPVSocketEvent OsclSendToMethod::SendTo(const uint8* &aPtr, uint32 aLen,
                                        OsclNetworkAddress& aAddress,
                                        int32 aTimeout)
{
    if (!StartMethod(aTimeout))
        return EPVSocketFailure;

    SendToRequest()->SendTo(aPtr, aLen, aAddress);

    return EPVSocketPending;
}
/**
 *  This method is called when we receive a WPD_COMMAND_SERVICE_METHODS_START_INVOKE
 *  command.
 *
 *  The parameters sent to us are:
 *  - WPD_PROPERTY_SERVICE_METHOD: Indicates the method to invoke.
 *     This must be from the list returned by WPD_COMMAND_SERVICE_CAPABILITIES_GET_SUPPORTED_METHODS
 *     or WPD_COMMAND_SERVICE_CAPABILITIES_GET_SUPPORTED_ METHODS_BY_FORMAT.
 *
 *  - WPD_PROPERTY_SERVICE_METHOD_PARAMETER_VALUES: IPortableDeviceValues containing the method parameters.
 *     Each parameter must be set in the ordering specified by WPD_PARAMETER_ATTRIBUTE_ORDER, with all parameters present.
 *     This must be an empty set if the method does not have any parameters.
 *
 *  The driver should:
 *  - Return immediately with the method invocation context in WPD_PROPERTY_SERVICE_METHOD_CONTEXT.
 *  - When this method invocation completes, the driver must send a WPD_EVENT_SERVICE_METHOD_COMPLETE event
 *    with the WPD_EVENT_PARAMETER_SERVICE_METHOD_CONTEXT parameter set as this method context.
 *  - Lastly, the driver should wait for the WPD_COMMAND_SERVICE_METHODS_END_INVOKE command
 *    before cleaning up associated resources with this context
 */
HRESULT WpdServiceMethods::OnStartInvoke(
    _In_    IPortableDeviceValues*  pParams,
    _In_    IPortableDeviceValues*  pResults)
{
    HRESULT hr          = S_OK;
    LPWSTR  pwszContext = NULL;

    // Create a new method context
    hr = StartMethod(pParams, &pwszContext);
    CHECK_HR(hr, "Failed to create a new method context");

    // Return the method context in the results
    if (SUCCEEDED(hr))
    {
        hr = pResults->SetStringValue(WPD_PROPERTY_SERVICE_METHOD_CONTEXT, pwszContext);
        CHECK_HR(hr, "Failed to set WPD_PROPERTY_SERVICE_METHOD_CONTEXT");
    }

    CoTaskMemFree(pwszContext);
    return hr;
}
TPVSocketEvent OsclAcceptMethod::Accept(int32 aTimeout)
{
    //in case previous accepted socket was never
    //retrieved...
    DiscardAcceptedSocket();

    iAcceptedSocket = OsclSocketI::NewL(Alloc());

    if (iAcceptedSocket->Open(*SocketServ()) != OsclErrNone)
    {
        DiscardAcceptedSocket();
        return EPVSocketFailure;
    }

    if (!StartMethod(aTimeout))
    {
        DiscardAcceptedSocket();
        return EPVSocketFailure;
    }

    AcceptRequest()->Accept(*iAcceptedSocket);
    return EPVSocketPending;
}