Thread: Client not receiving FD_CLOSE notification message?

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    17

    Unhappy Client not receiving FD_CLOSE notification message?

    Hi
    I have a client server application.
    Server is an mfc dialog based application.
    Client is an mfc sdi application.
    Winsock2 is used for communication.

    Both client & server are asynchronous in nature credits to WSAAsyncSelect().

    The client & the server are connected to each other:
    Now whenever i close the client socket, FD_CLOSE notification is send to the server but the vice versa is not happening.
    The client donot gets the FD_CLOSE notification when the server socket is closed.


    What cud be the possible problem?

    waiting for suggestions

    Regards

  2. #2
    Registered User
    Join Date
    May 2005
    Posts
    17
    Hi Guys
    I am waiting for some suggestions.
    Can any one plz help!

    Regards
    dp_76

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Once you've called closesocket you can no longer get notification messages for that socket because closesocket deletes the socket. FD_CLOSE is sent when a socket's connection is closed but the socket must still be valid.

    Quote Originally Posted by MSDN
    To assure that all data is sent and received on a connected socket before it is closed, an application should use shutdown to close connection before calling closesocket. For example, to initiate a graceful disconnect:

    Call WSAAsyncSelect to register for FD_CLOSE notification.
    Call shutdown with how=SD_SEND.
    When FD_CLOSE received, call recv until zero returned, or SOCKET_ERROR.
    Call closesocket.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Receiving a notification after resuming from sleep state
    By foxman in forum Windows Programming
    Replies: 7
    Last Post: 02-23-2008, 06:41 PM
  2. Replies: 40
    Last Post: 09-01-2006, 12:09 AM
  3. Character arrays in a Structure
    By vsriharsha in forum C Programming
    Replies: 7
    Last Post: 07-11-2004, 05:36 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM