Thread: WSAAsyncSelect I/O Mode :: Winsock

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    WSAAsyncSelect I/O Mode :: Winsock

    Hi.

    I am getting closing to completing a simple messaging program. I will use the WSAAsyncSelect I/O mode. The design is simple, but I have found a major problem. The WSAAsyncSelect is not the best I/O mode, but it is easy to implementing for MFC based applications.

    WSAAsyncSelect uses the winproc as a way to update the program about sockets including send, receive, close, accept, etc. So basically, the WSAAsyncSelect I/O mode turns an otherwise blocking socket into a non-blocking socket. It uses the WPARAM and LPARAM to store errors and data structures required to, for example, create a new socket linked to the user that is trying to connect to the server.

    Now comes the problem. I declared all program data such as the socket, listening socket, sockaddr, etc. in the doc. However, WSAAsyncSelect sends a message with the WPARAM and LPARAM to main frame. I have no idea how to pass WPARAM and LPARAM from main frame to doc so I can process the data.

    I see two possible solutions.

    1) pass WPARAM and LPARAM from main frame to doc
    2) redirect WPARAM and LPARAM from main frame to doc view SendMessage(). However, doc cannot process WM_USER message, can it? I cannot find the SendMessage() for doc.

    Please post if you have a working solution for the WSAAsyncSelect I/O mode.

    Thanks,
    Kuphryn

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. I believe I have a solution. However, I am debugging another problem, so I am not completely sure that the solution works.

    The solution I implemented compiled, but I have not fully tested it. The solution is to pass the a reference of wParam to doc.

    I like this solution because I do not have to use a pointer to doc just to access its private data. This solution keeps the OOP encapsulation standard intact.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock WSAAsyncSelect
    By High in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 12:20 AM
  2. Complete Port I/O and Heap Problems :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 11-05-2002, 12:45 AM
  3. I/O Completion Port and Queue Status :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 11-02-2002, 01:00 PM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM
  5. WSAAsyncSelect I/O & Multithreading :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 4
    Last Post: 09-27-2002, 02:28 AM