Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question about recv() in Winsock

Question about recv() in Winsock

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nachilau
    wrote on last edited by
    #1

    Hello, I am using recv() in my Server, cout << "First recv..." << endl; recv(clientS, r, 6, 0); cout << "Second recv..." << endl; recv(clientS, r, 6, 0); and in the client side, I do not send any message after I have connected to the server. However, the output of the server is First recv... Second recv... I just wonder that the recv() should be blocking operation, but how come it does not wait for the message come before it goes to another statement? Thanks for help! Nachi

    J 1 Reply Last reply
    0
    • N nachilau

      Hello, I am using recv() in my Server, cout << "First recv..." << endl; recv(clientS, r, 6, 0); cout << "Second recv..." << endl; recv(clientS, r, 6, 0); and in the client side, I do not send any message after I have connected to the server. However, the output of the server is First recv... Second recv... I just wonder that the recv() should be blocking operation, but how come it does not wait for the message come before it goes to another statement? Thanks for help! Nachi

      J Offline
      J Offline
      jmkhael
      wrote on last edited by
      #2

      again MSDN: If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives. Papa Murex Co. while (TRUE) Papa.WillLove ( Bebe ) ;

      N 1 Reply Last reply
      0
      • J jmkhael

        again MSDN: If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives. Papa Murex Co. while (TRUE) Papa.WillLove ( Bebe ) ;

        N Offline
        N Offline
        nachilau
        wrote on last edited by
        #3

        I am sorry, I actually don't quite understand. The client haven't send any message to the server, how come the recv() does not wait? Actually, I have already read that documentation before, but I don't understand.... Thanks! Nachi:confused:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups