winsock's senddata & getdata problem

Discussion in 'MFC' started by yoz1ris, Jan 21, 2009.

  1. yoz1ris

    yoz1ris New Member

    Joined:
    Jan 16, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    company worker
    Location:
    southern asia
    Dear friends:shy:,
    I have try to make a simple program that asks users to input sth (name, age, etc) in computer A.
    And then, the program (in comp A) sends the collected data to comp. B via winsock.
    I expect the program in comp B to list the result as follow.

    Name Age Sex
    ------- ---- ---
    John 20 M
    Diane 18 F
    Xisco 50 M
    Wang 46 F

    But, in point of fact the program (in comp B) shows the result like this:
    Name Age Sex
    ------- ---- ---
    John 20 M Diane 18 F Xisco 50 M ...
    John 20 M Diane 18 F Xisco 50 M ...
    ...
    John 20 M Diane 18 F Xisco 50 M ...
    John 20 M Diane 18 F Xisco 50 M ...

    Please, could anybody help me find the solution?:embarasse
    Sincerely yours,

    yoz1ris

    Excerpt of the code:
    ...(in a module of program A)...
    If lResult <> 0 Then _
    strDat = strName & vbTab & strAge & vbTab & strSex
    frmSend.w2.SendData strDat
    End Function

    ...(in a form of program B)...
    Private Sub w1_DataArrival(ByVal bytesTotal As Long)
    Dim strDat As String
    w1.GetData strDat
    lstProc.AddItem strDat
    End Sub
    -------end of excerpt-------
     
  2. Cosmic_egg

    Cosmic_egg New Member

    Joined:
    Jul 21, 2008
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    0
    comp B is just displaying what is sent in COMP A
    Why don't you format the data either before sending or after receiving to display it according to your need.

    There seems to be no problem with senddata and getdata
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice