August 4th, 2003, 06:50 AM
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.
August 4th, 2003, 02:55 PM
you should be setting the last parameter to 0 to do normal reads.
August 5th, 2003, 02:59 AM
I thought MSG_PEEK was a macro for 0? Anyway, it doesn't work either :(
August 5th, 2003, 03:33 AM
where's the rest of the code? what is being sent? are you sending it correctly?
August 5th, 2003, 04:04 AM
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.
August 5th, 2003, 01:02 PM
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.