Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Send text trough a socketconnection in Visual C++?

Hello my best friends,

I'm a beginner to Visual C++ programming, so I have some "stupid" questions for you and I hope you guys to help me.

I'm working on my own very simple chatapplication, but I encounterd some problems. I've made a client and a server part, I've tested it out but I had the problem that I couldn't send a text string. My serverside establishes a connection with the clientside ( I know it because I put some control messages to be sure there is a connection).

But when I try to send a peace of text, it does nothing except that it shows the sending text on my display and the receiver part shows nothing on the display. I used the following code to send a string:

void CSimComDlg::OnSend()
{
m_Message.GetWindowText(strMESSAGE);
m_pArOut->WriteString(strMESSAGE);
m_pArOut->Flush();
m_MsgDsp.SetWindowText(_T(Name+":"+strMESSAGE+"
"));
strMESSAGE.Empty();
}

And to read a received string:

void CSimComDlg::ReadReceive()
{
m_pArIn->ReadString(strMESSAGE);
m_MsgDsp.SetWindowText(_T("Chatter:"+strMESSAGE+"
"));
strMESSAGE.Empty();
}

m_pArOut and m_pArIn are CArchive pointers (I use this in combination with CSocketFile to send data over internet).

Is there something wrong with these codes?

I've seen some other example codes on the internet, they include also the length of the message to send and they check also the buffer if there's more data coming in. But are they neccesary to put them in my code?

I hope you can help me boyzz, thank you very much!
Sign In or Register to comment.