I have a server and a client. I wrote handlers for send button and receive. When I send a string I am receiving only first two chars and then some japanese chars of the string on the receive side. I wanna receive the entire string.Please help me . This is my code:
void CsocketDlg::OnClickedBsend()
{
// TODO: Add your control notification handler code here
int iLen;
int iSent;
//sync controls with variables
UpdateData(TRUE);
//if(m_dSetThresholdFineDfLB.Create()==IDOK)
//m_strMessage = m_dSetThresholdFineDfLB.m_sFrameLB;
//UpdateData(FALSE);
if(m_strMessage != " ")
{
iLen = m_strMessage.GetLength();
//send the message
iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage),iLen);
//were we able to send the message
if(iSent == SOCKET_ERROR)
{
}
else
{
//Add the message to the list box
m_ctlSent.AddString(m_strMessage);
//sync the variables with the control
UpdateData(FALSE);
}
}
}
void CsocketDlg::OnReceive(void)
{
//char *pBuf = new char[1025];
TCHAR *pBuf = new TCHAR[1025];
int iBufSize = 1024;
//int iBufSize = sizeof(pBuf);
int iRcvd;
// CString strRecvd;
TCHAR *strRecvd = new TCHAR[1025];
//receive the message
iRcvd = m_sConnectSocket.Receive(pBuf, iBufSize);
//did we receive anything?
if(iRcvd == SOCKET_ERROR)
{
}
else
{
//truncate the end of the message
pBuf[iRcvd] = NULL;
//copy the message to CString
//LPCWSTR wcscpy(LPCWSTR strRecvd ,LPCWSTR pBuf);
wcscpy(strRecvd,pBuf);
//strRecvd = pBuf;
//CString strRecvd(pBuf);
//add the message to the received list box
m_ctlRecvd.AddString(strRecvd);
// m_ctlRecvd.InsertString(0,strRecvd);
//sync the variables with the controls
UpdateData(FALSE);
//m_ctlRecvd.UpdateData(FALSE);
}
}