Results 1 to 3 of 3

Thread: Problems storing packet data(bytes) in a byte array using Vb.Net.....

  1. #1

    Thread Starter
    Lively Member nemesys777's Avatar
    Join Date
    Nov 2001
    Posts
    103

    Unhappy Problems storing packet data(bytes) in a byte array using Vb.Net.....

    Hi,
    I'm trying to recieve a packet of data from a client application and store the bytes of that packet into a byte array. There are 62 bytes of data in the packet. . This is what I have so far..

    Code:
    Public Sub Listen()
            Dim SocketStream As NetworkStream
            Dim connection as socket
            Dim reader as binaryreader
            Dim listener As New TcpListener(5000)
            listener.Start()           
            TextBox1.Text &= vbCrLf & "Awaiting Connections.." 
            connection = listener.AcceptSocket()
    
             SocketStream = New NetworkStream(connection) 
             reader = New BinaryReader(SocketStream) 
    
             Dim bytearray As New BitArray(62) 'PROBLEM LINE #1
             bytearray = reader.ReadBytes(62) 'PROBLEM LINE #2
    
        End Sub
    I want to read the first packet from the client and store it in a byte array:
    bytearray = reader.ReadBytes(62) ????
    I might not be declaring byte array correctly. My error comes up on the line
    bytearray = reader.ReadBytes(62)
    It says ": Value of type '1-dimensional array of Byte' cannot be converted to 'System.Collections.BitArray'."

    Any help on this would be great. Thanks in Advance.

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    VB Code:
    1. '       Dim bytearray As New BitArray(62)
    2.  ' try using
    3.          Dim bytearray(62) as Byte

    this should solve problem #2 as well.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Lively Member nemesys777's Avatar
    Join Date
    Nov 2001
    Posts
    103
    Thanks man..I swear I tried that first...must have done something wrong..anyhow..it works fine now..Thx

Posting Permissions

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



Click Here to Expand Forum to Full Width