I’m using non-blocking sockets with winsock and I wonder that if I can partially receive data ?
My packet contains a “length” WORD and I must first read it then read whole packet according to the “length”.
Actually this question is like “how does recv() work and end ?”, Can i use recv() until I got all the data ?
It depends on the type of the socket. If it’s a datagram socket,
recvwill read exactly one entire datagram. If it’s a TCP socket:recvwill read at least one byte before returningrecvcan read more than one completemessageIf you’re using TCP, you’ll probably want to do something like this:
lengthbytesYou could start with the
readnfunction.