PDA

Click to See Complete Forum and Search --> : Problems storing packet data(bytes) in a byte array using Vb.Net.....


nemesys777
May 21st, 2002, 04:20 PM
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..


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.

sunburnt
May 21st, 2002, 06:01 PM
' Dim bytearray As New BitArray(62)
' try using
Dim bytearray(62) as Byte


this should solve problem #2 as well.

nemesys777
May 22nd, 2002, 11:51 AM
Thanks man..I swear I tried that first...must have done something wrong..anyhow..it works fine now..Thx