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

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
00061205
Knows some wx things
Knows some wx things
Posts: 41
Joined: Mon Jun 16, 2008 3:43 am
Location: Beijing, China

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

Post 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.
Regards,

00061205
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Post 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
00061205
Knows some wx things
Knows some wx things
Posts: 41
Joined: Mon Jun 16, 2008 3:43 am
Location: Beijing, China

Post 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:
Regards,

00061205
Post Reply