#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0

    recv() only accepting one character (winsock2)


    I use the recv() function like this:

    int msgLength = recv(sockMain, buf, 20, MSG_PEEK);

    No errors are reported by the return value, but recv() seems to only accept one character. It stops recv()-ing after I enter one character from the client. Is there a reason for this?

    If i set the flag to MSG_OOB, which seemed to be the only thing I could have gone wrong at, it doesn't stop recieving...

    Any help appreciated

    *Edit: I use winsock2.
  2. #2
  3. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    you should be setting the last parameter to 0 to do normal reads.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    I thought MSG_PEEK was a macro for 0? Anyway, it doesn't work either :(
  6. #4
  7. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    where's the rest of the code? what is being sent? are you sending it correctly?
  8. #5
  9. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    Are you sending only one byte at a time?

    Are you calling recv() until it returns an error or 0 (no more data) ?
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    6
    Rep Power
    0
    I seem to have found the problem. I was using telnet to test out my server. I wrote up a quick TCP Client, and transmitted over that, and it worked fine. I suppose it causes telnet to transmit as soon as It recieves input.

    Anyway, thanks for the help guys.

IMN logo majestic logo threadwatch logo seochat tools logo