views:

32

answers:

1

Hello,

I would like to ask a question about correct way of canceling socket operations on Symbian. Basically, we have two options, as far as I understand:

  1. Call CActive::Cancel() on a ActiveObject that is used for asynchronous requests.
  2. Call RSocket::CancelRead() or RSocket::CancelSend() or RSocket::CancelAll()

Which way is correct? Or maybe I should call both methods - from CActive and from RSocket?

Thanks in advance.

A: 

I haven't wrote anything using RSocket class, but from it's API I guess it's used like this: you have an AO and you pass it's iStatus to one of the RSocket asynchronous methods (Send(), Read(), Recv(), etc.). In that case you should call cancel on RSocket (CancelSend() if you passed iStatus to Send(), CancelRead() if you used Read(), etc. or just CancelAll()), and it will complete your AO with KErrCancel.

chalup
But what is the difference between these two approaches? What will be if I call AO::Cancel() instead of RSocket::CancelRead() or such?I'm asking because this operation (read canceling) hangs in a certain conditions.
Haspemulator
I assumed that the RSocket is a member in your AO, which wraps all the network operations. So to cancel RSocket operation you should cancel AO, and in CYourAO::DoCancel() it should call RSocket::CancelXXX(). Check out this example: http://wiki.forum.nokia.com/index.php/How_to_Make_an_HTTP_Connection_Using_TCP/IP_with_RSocket
chalup
Well, I looked at that example you provided. It is pretty straightforward, but in real world things are little bit more complicated. If you would like to do recv and send simultaneously, you need 2 AO. So, they should be separate from socket, because they don't own it. But it's okay. Just need to make additional call from readAO and sendAO to their owner (who owns socket too), and cancel respective operation there. Thanks, now it seems more clear.
Haspemulator