Results 1 to 3 of 3

Thread: Endreceive when Formclosing is intiated

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    2

    Endreceive when Formclosing is intiated

    Hi,

    I am programming a server-client socket software. On client side, when I click on the close window at the right upper side [X] Formclosing is initiated. I want to send to the server some information about disconnecting socket. My problem is that the client is in receiving state and I need to stop receiving state by calling socket.endreceive. I can't do that in Formclosing cause It need IASyncResult object that is not accessible.

    Is there a way to achieve that?

    many thanks.

    Patrice

  2. #2
    Addicted Member
    Join Date
    Oct 2008
    Location
    USA
    Posts
    150

    Re: Endreceive when Formclosing is intiated

    I feel/think you are misunderstanding the purpose of socket.endreceive.
    see this link
    http://msdn.microsoft.com/en-us/library/w7wtt64b.aspx

    Try closing the socket in the Formclosing method. This will cause socket.endreceive to throw an ObjectDisposedException exception.
    Handle this exception in a try catch block.
    Last edited by 2ndmessiah; Jun 4th, 2013 at 11:06 AM. Reason: Pitiful bad spelling and grammar.
    Think.... Question.....

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    2

    Re: Endreceive when Formclosing is intiated

    Quote Originally Posted by 2ndmessiah View Post
    I feel/think you are misunderstanding the purpose of socket.endreceive.
    see this link
    http://msdn.microsoft.com/en-us/library/w7wtt64b.aspx

    Try closing the socket in the Formclosing method. This will cause socket.endreceive to throw an ObjectDisposedException exception.
    Handle this exception in a try catch block.

    Thank you for the answer. I know what endreceive does. What I want to do is currently using endreceive to stop reading state and sending a message to the server side. But on FormClosing, I don't see how I can call endreceive without IaSync object.

    do you have any idea on what I can do?

    many thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width