dcsimg
Results 1 to 2 of 2

Thread: Reading List View Column no 4 of each row does not give proper result

  1. #1

    Thread Starter
    Registered User
    Join Date
    Nov 2018
    Posts
    1

    Reading List View Column no 4 of each row does not give proper result

    Hello Masters,

    first of all i'm sorry - my english is not good.

    My issue is I've been trying to read ListView1.ListItems(i).SubItems(4) in loop. It Shows the result but in a bundle.

    Say for example I have 3 rows and 5 columns, I want to read ListView1.ListItems(i).SubItems(4) data and send to server separately, But when the loop starts it gives the result of all three rows in a bundle and sends it to server - which the server is unable to understand.

    here is my code

    Dim xt As String
    Dim i as Integer
    For i = 1 To LV.ListItems.Count
    xt = LV.ListItems(i).SubItems(4)
    Form1.Winsock1.SendData (".GetRates" & " " & xt & " " & Trim(Form1.cmbUsername.Text))
    Next i


    please help me

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,332

    Re: Reading List View Column no 4 of each row does not give proper result

    TCP is a stream protocol.

    This means anything you send is joined to whatever you have sent previously.

    At the receiver this data arrives in bursts of bytes from 1 to many up to usually 8192 (the default buffer size in Windows and probably most OSs).

    There are no "sends" only a long, bursty send. TCP is not a message oriented protocol.

    You have fallen into a trap I call "the packet fallacy" because people often talk about "sending packets" which you are not doing when you use a TCP socket.

    If you intend to do messaging over a TCP connection you must make use of some application protocol on top of TCP. This might be as simple as sending some "end of message" character after the data.


    We have the same issue with text files. These are stream files, and do not have "lines" at all. By convention a CR, LF, or CRLF are used to separate "lines." Since this convention is so common we often have things like Line Input statements that know about this and break up the stream into "lines." VB's Line Input will treat any CR or CRLF as "new line" and any Ctrl-Z as End Of File.

    But Winsock can't do this for you because it can't make assumptions about the data stream like a Text input reader can.


    So you need to choose some scheme your client and server both agree on. You could use a CR or CRLF delimiter, or you might begin each "line" with a length prefix. Sending "length" and then "data" is more common for binary data where there is no single character or character pair that can't occur within the data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width