Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Sending strings (or characters) through sockets.

Sending strings (or characters) through sockets.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpsysadmintutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SimCom
    wrote on last edited by
    #1

    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+"\r\n")); strMESSAGE.Empty(); } And to read a received string: void CSimComDlg::ReadReceive() { m_pArIn->ReadString(strMESSAGE); m_MsgDsp.SetWindowText(_T("Chatter:"+strMESSAGE+"\r\n")); 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? :doh: 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 :-O If my application works, I forget all my problems.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups