I've been having this issue with WxWidgets C++ WxSockets for the past couple of days and I cannot seem to get it. I am trying to write data towards a server, in which I have already connected to. However, whenever I try to use the read() function, I am getting multiple errors (picture attached below) and it is really frustrating me. FYI, I am a complete newbie (I picked up wxwidgets about 2-3 days ago). I've been through a lot of the forums on here and it's helped me a lot, but this is as far as I got! Here is my code...
Wxwidgets C++ : 3.1.1
Visual Studio 2013
Code: Select all
void MyFrame::OnEnterText(wxCommandEvent &event){
// Adds new command into menu of previously used
wxString temp = commandScripts->GetLineText(0);
this->p_commands.Add(temp);
this->previousCommands->Clear();
this->previousCommands->Append(p_commands);
wxCharBuffer buf(len * 1024);
wxCharBuffer *buf2 = new wxCharBuffer(len * 1024);
// If read/write, send accordingly
// I am hard coding here to send in user input
// When I write to the box command, it'll say
// "write 0x12345678"
// And then I'll read the data that I just sent
// read
if (temp[0] == 'r'){
socket->SetFlags(wxSOCKET_WAITALL);
wxSocketBase& temp2 = socket->Read(buf2, len * 1024);
// I want the data I'm reading back in to be able to be displayed
// on my main command display
//const char *readData = *buf2;
//commandDisplay->WriteText(readData);
}
else if (temp[0] == 'w'){
socket->SetFlags(wxSOCKET_WAITALL);
// Gather user's input
char cstring[1024];
wxString temp1 = "";
for (int i = 6; i < temp.length(); i++){
temp1 += temp[i];
}
// Changing user's input into buffer ready for server
strncpy(cstring, (const char*)temp1.mb_str(wxConvUTF8), 1023);
const char *buf1 = cstring;
wxCharBuffer buf2(wxStrlen(buf1));
// Write out to display prompt
socket->Write(buf1, len);
commandDisplay->WriteText("Write Finished\n");
}
}
I am not just looking for answers, explanations would be the best because I really want to learn why it's behaving like this!!!
Thank you so much for your time and help!!
- Derek