|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
you should be setting the last parameter to 0 to do normal reads.
|
|
#3
|
|||
|
|||
|
I thought MSG_PEEK was a macro for 0? Anyway, it doesn't work either
![]() |
|
#4
|
||||
|
||||
|
where's the rest of the code? what is being sent? are you sending it correctly?
|
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > recv() only accepting one character (winsock2) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|