I can’t get the DatagramSocket class to work, this is what i more or less what i do. (OSX)
//pseudocode
socket = new DatagramSocket(port);
startThread();
while (!threadShouldExit())
{
int result = dgSocket->waitUntilReady(true, 100);
if (result) {
int sizeRead = socket->read(data, dataSize);
}
}
I think there is a bug in the DatagramSocket.
In the constructor the the DatagramSocket connected is set to false.
However when calling waitUntilReady or read the connected flag is checked, so those functions will always fail.
[code]
DatagramSocket::DatagramSocket (const int localPortNumber)
: portNumber (0),
handle (-1),
connected (false),
serverAddress (0)
{
#if JUCE_WIN32
initWin32Sockets();
#endif
handle = (int) socket (AF_INET, SOCK_DGRAM, 0);
bindToPort (localPortNumber);
}
int DatagramSocket::waitUntilReady (const bool readyForReading,
const int timeoutMsecs) const
{
return connected ? waitForReadiness (handle, readyForReading, timeoutMsecs)
: -1;
}
int DatagramSocket::read (void* destBuffer, const int maxBytesToRead)
{
return connected ? readSocket (handle, destBuffer, maxBytesToRead, connected)
: -1;
}
[/code][
Am i missing something, i’m using revsion 684, but i saw that the code in the tip is more or less the same.
