now they can send message and file to each other as well.
it is the code that send text message:
Code: Select all
const wxChar* buf;
wxString text = TextCtrl1->GetValue();//text that to send
buf = text.c_str();
wxUint32 len = (wxStrlen(buf)+1)*sizeof(wxChar);//size of data
clientSocket->Write(buf,len);
Code: Select all
wxFile file;
file.Open(wxT("test.txt"),wxFile::read);//read mode
size_t fileSize = file.Length();//file size
wxUint8* buffer = new wxUint8[fileSize];
size_t len = file.Read(buffer,fileSize);//read data in buffer
clientSocket->Write(buffer,len);//send
delete []buffer;
file.Close();
could read wxChar* and wxUint8* success and work well.
but our server how to get the type that received data?
if data is wxChar* ,I will show it on gui,and if data id wxUint8*,
I will save it to a file. Could any body help me?