who could help me for error number 10035

This is a discussion on who could help me for error number 10035 within the Windows Programming forums, part of the Platform Specific Boards category; I write server and client,and linking using SOCK_STREAM.at server I send a file and at client I receive it,and at ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    50

    who could help me for error number 10035

    I write server and client,and linking using SOCK_STREAM.at server I send a file
    and at client I receive it,and at client I use:
    WSAAsyncSelect(m_socket,m_hWnd,WM_SOCK,FD_READ);
    and look:
    Code:
    void CChatCDlg::OnSock(WPARAM wParam,LPARAM lParam)
    {
    	switch(LOWORD(lParam))
    	{
    	case FD_READ:
    			wlength = recv(m_socket,buffer,8000,0);
    			if(SOCKET_ERROR == wlength) 
    			{ 
                                 int err=WSAGetLastError();
    			      CString str;
    			      str.Format("Error number:%d",err);
                                  AfxMessageBox(str);  
    			      return; 
    			} 
    		break;
    	}
    }
    I get the error number is 10035,I want to know how to correct?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The error message you are getting is WSAWOULDBLOCK, basically indicating that recv is in non-blocking mode and there is no data, so it would block and wait for data if the call proceeded. It's also possible from the error description that your connection has not stabilized and might cause errors if recv continued.

    Windows Sockets Error Codes (Windows) (When in doubt... look it up!)

    So... are you using non-blocking sockets?

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    50
    I use WSAAsyncSelect(m_socket,m_hWnd,WM_SOCK,FD_READ);
    how to correct it?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Are you intending to use blocking sockets? I would guess "no", just based on the word "chat" in the original code.

    To "fix it", you need to wait until the person on the other end says something, or better yet, do whatever is the WSA equivalent of select to check whether there is data waiting.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by tabstop View Post
    Are you intending to use blocking sockets? I would guess "no", just based on the word "chat" in the original code.

    To "fix it", you need to wait until the person on the other end says something, or better yet, do whatever is the WSA equivalent of select to check whether there is data waiting.
    select function (Windows)

    Calling select() with the right setups will tell him which sockets have pending data... from there he can call recv().

    WSAAsyncSelect() is a way of setting up window messages so that he gets notification in his message loop whenever a socket event occurs... It's not wrong, but it's really intended to work with blocking sockets... The idea is that when you get a message notifying you of a pending message you call recv() or recvfrom()...

    http://msdn.microsoft.com/en-us/libr...40(VS.85).aspx

    Overall it would be simpler to set up a separate thread to handle and display received messages, using blocking sockets. It could just sit there in recv() waiting for a message then when recv() unblocks the thread could display the message in a windows control such as a listbox or edit on the user interface and then go right back to receiving.
    Last edited by CommonTater; 08-18-2011 at 08:48 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 09-24-2010, 02:09 AM
  2. Random Number Generator - Error
    By Excelisus in forum C Programming
    Replies: 23
    Last Post: 09-06-2010, 12:07 AM
  3. why error while the number is very big ?
    By zcrself in forum C Programming
    Replies: 7
    Last Post: 08-31-2009, 07:55 AM
  4. Program to reverse a number. small error with it..
    By comproghelp in forum C Programming
    Replies: 8
    Last Post: 11-22-2004, 10:52 AM
  5. Variables number of arguments error
    By xErath in forum C Programming
    Replies: 3
    Last Post: 11-19-2004, 10:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21