Winsock recvfrom, message length
Posted on 2004-04-17
I'm porting a unix socket (UDP) app to windows. On unix, recvfrom will return the length of the message (even if it didn't fit in the buffer i passed to the function). I need to obtain the length of the incoming message, but this seems to be somehow messed up in the MS API, which returns -1 on failure and never seems to be able to give me the message length. On success, of course it gives me the actual number of bytes I got. However this is rather uninteresting since by then I've obviously already allocated a proper buffer. I need to know ahead of time what size buffer is needed to hold the message. I'd be very happy if someone could tell me what function I need to use to do this on windows ASAP.