I have an SFML 1.6 non-blocking UDP socket which I am receiving raw data from. As per the example in the tutorial I am calling Skt.Receive(), passing in a buffer to fill. When the buffer is too small to fit the data, Receive() returns sf::Socket::Error.
Unfortunately I appear to have no way of distinguishing this (easily rectified!) error from more serious errors that may have occurred. WSAGetLastError() on Win32 returns a specific error code WSAEMSGSIZE when the buffer is too small, and a little research shows *nix puts EMSGSIZE in the errno variable to indicate the same issue. However, checking these rather defeats the point of using SFML for cross-platform compatibility.
So, in an attempt to do things "the SFML way": is there a way I can peek at the top message in the socket's recv buffer to determine how long it is? Or a way to get the socket to truncate the message and return the data up to the size I passed in (as the standard implementation of recvfrom() does)?
I could simply allocate an array of size 65516 (the maximum amount of data you can fit into an IP packet), but that's a really poor workaround.
Any tips, or should I break out the #ifdefs and write my own error lookups to catch this situation?
edit:\ Just noticed a similar thread
here - I guess I'm doing it myself.