Page 1 of 1

How to know wether there are more data in socket to be read?

Posted: Fri Jul 25, 2008 3:03 am
by 00061205

Code: Select all

void netdbgFrame::OnSocketEvent(wxSocketEvent& event)
{
    wxString s = _("");
    char cBuf [257];
    wxString wxstrBuf=wxT("");
    wxSocketBase *sock = event.GetSocket();
    strtemp="";
    memset( cBuf, 0, 257 );

    switch (event.GetSocketEvent())
    {
    case wxSOCKET_INPUT      :
        sock->Read(cBuf,256);
        strtemp+=cBuf;
        wxstrBuf=wxString(strtemp.data(), *wxConvCurrent);
        s.Append(wxstrBuf);
        break;    
    }
}
Is there a way to know wether there are more data in socket to be read after read 256 byte(sock->Read(cBuf,256)). In other word, I want to know wether I read all data from socket.

Posted: Fri Jul 25, 2008 6:14 am
by mc2r
Not sure if this helps but wxSocketBase::IsData() might be what you are looking for. I don't use wx for networking stuff, so i've not tried it.

-Max

Posted: Fri Jul 25, 2008 7:15 am
by 00061205
mc2r wrote:Not sure if this helps but wxSocketBase::IsData() might be what you are looking for. I don't use wx for networking stuff, so i've not tried it.

-Max
Thanks, Max. I tried wxSocketBase::IsData(). It didn't work as I want. :lol: