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]; int iBufSize = 1024; int iRcvd; CString strRecvd; //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 strRecvd = pBuf; //add the message to the received list box m_ctlRecvd.AddString(strRecvd); //sync the variables with the controls UpdateData(FALSE); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)