Hi, Igor and thank you for your answer.
Unfortunatelly I haven't got a patch, but I'm trying to investigate if what I've observed could be a bug or not.
Simply I've wanted to use the example delivered with wxWidgets library to understand whether even with such code was present the same and strange behaviour I've observed in my application or not.
Up to now, I'm able only to confirm that also using the example above mentioned the behaviour which look like a memory leack problem is present.
I've modified just a bit the original example's source code in order to introduce a loop into the first test. (Client side)
I'm not sure that the behavior I've observed is a bug, because i think that sockets features in wxWidgets library was already present for long.
And it seems surprising that noone stumbled over such kind of problem before now.
Many thanks for your time.
Feel free to ask me for other details if you need.
*************************
CLIENT SIDE CODE
*************************
void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
{
int count = 5000;
// Disable socket menu entries (exception: Close Session)
m_busy = true;
UpdateStatusBar();
do {
DoTest1();
count--;
} while (count > 0);
m_busy = false;
UpdateStatusBar();
}
void MyFrame::DoTest1()
{
m_text->AppendText(_("\n=== Test 1 begins ===\n"));
// Tell the server which test we are running
unsigned char c = 0xBE;
m_sock->Write(&c, 1);
// Send some data and read it back. We know the size of the
// buffer, so we can specify the exact number of bytes to be
// sent or received and use the wxSOCKET_WAITALL flag. Also,
// we have disabled menu entries which could interfere with
// the test, so we can safely avoid the wxSOCKET_BLOCK flag.
//
// First we send a byte with the length of the string, then
// we send the string itself (do NOT try to send any integral
// value larger than a byte "as is" across the network, or
// you might be in trouble! Ever heard about big and little
// endian computers?)
m_sock->SetFlags(wxSOCKET_WAITALL);
const char *buf1 = "Test string (less than 256 chars!)";
unsigned char len = (unsigned char)(wxStrlen(buf1) + 1);
wxCharBuffer buf2(wxStrlen(buf1));
m_text->AppendText(_("Sending a test buffer to the server ..."));
m_sock->Write(&len, 1);
m_sock->Write(buf1, len);
m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
m_text->AppendText(_("Receiving the buffer back from server ..."));
m_sock->Read(buf2.data(), len);
m_text->AppendText(m_sock->Error() ? _("failed !\n") : _("done\n"));
m_text->AppendText(_("Comparing the two buffers ..."));
if (memcmp(buf1, buf2, len) != 0) {
m_text->AppendText(_("failed!\n"));
m_text->AppendText(_("Test 1 failed !\n"));
}
else {
m_text->AppendText(_("done\n"));
m_text->AppendText(_("Test 1 passed !\n"));
}
m_text->AppendText(_("=== Test 1 ends ===\n"));
}
*************************
SERVER SIDE CODE
*************************
void MyFrame::Test1(wxSocketBase *sock)
{
TestLogger logtest("Test 1");
// Receive data from socket and send it back. We will first
// get a byte with the buffer size, so we can specify the
// exact size and use the wxSOCKET_WAITALL flag. Also, we
// disabled input events so we won't have unwanted reentrance.
// This way we can avoid the infamous wxSOCKET_BLOCK flag.
sock->SetFlags(wxSOCKET_WAITALL);
// Read the size
unsigned char len;
sock->Read(&len, 1);
wxCharBuffer buf(len);
// Read the data
sock->Read(buf.data(), len);
wxLogMessage("Got the data, sending it back");
// Write it back
sock->Write(buf, len);
}