×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Dec 2003
    Location
    Munich, Germany
    Posts
    30

    Closing a Socket Connection

    Hi

    I am having trouble closing my socket connection.

    I have a class, that owns the RSocket object, manages the connection (connect, disconnect etc) and that issues writes on the socket.

    And I have another class, that just reads from the socket.

    Both classes derive from CActive.

    When I want to close the connection the following code is to be executed in the Writer/Manager class:

    iListener->Cancel(); // iListener is the Reader object
    iSocket.Close(); // close the socket after the Reader's outstanding read request has been cancelled.

    But when the Reader's Cancel() method is executed the application panics: "KERN-EXEC 3". The Symbian documentation tells something about unhandled exceptions, but what exception are being thrown here, and how can they be caught?

    I have no idea what the mistake is, the code is mostly copied from an example application...

    Thanks for any hints in advance,

    Maniac

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144
    the KERN-EXEC 3 is memory violation. Basically means using a pointer that is invalid. There are basically two main causes to this error:

    1. Trying to use pointer that has NULL value (i.e. not pointing to any object)

    2. Using a pointer that is pointing to a memory location that does not have object in it. Usually trying to use object that was deleted previously.

    The beast way to prevent this error is to check pointers before using them. Basically just checking that they are something else than NULL. And making sure that every single object when deleted is set to NULL strait in a next line.

    yucca

  3. #3
    Registered User
    Join Date
    Dec 2003
    Location
    Munich, Germany
    Posts
    30

    Very weird...

    Hi Yucca!

    Well, I have been trying to check the pointer, that might cause the panic. However, the pointer should be ok. I implemented a Test method into the class, that the pointer is pointing at, and I tried to run that method using the pointer. Works!

    Anyways, I am just instantiating that particular class with the NewL/NewLC construct, putting a pointer on the object. So I cannot find anything that might screw up the pointer or the memory that it's pointing at.

    So the problem why the program panics must be on calling the Cancel() method. But why? Cancel just means to cancel any outstanding requests, doesn't it? Why does it crash then?

    Maniac

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    Hi,
    have you implemented CActive:oCancel() in your class?

  5. #5
    Registered User
    Join Date
    Dec 2003
    Location
    Munich, Germany
    Posts
    30
    Yes. I have.

    Otherwise the code wouldn't even compile, though doCancel() is abstract...

    Maniac

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •