1st off, thanks for the fast reply.
I'm sure it only contains ASCII characters.
The data IS usualy shorter than the buffer length, so yes there are tailing
zeros in the byte array.
Is there a fix to get around this problem?
Here's some of the code I am having the problem with
Private rBuffer(rBufferSize) As Byte
Private Const rBufferSize As Integer = 1024
Private Sub LocalDataArrivalEvent(ByVal ar As IAsyncResult)
Dim strTEMP_DATA As String
Dim strBDR As System.Text.StringBuilder
Try
Dim read As Integer = lSocket.EndReceive(ar)
If read > 0 Then
strTEMP_DATA = Encoding.ASCII.GetString(rBuffer)
RaiseEvent DataArrival(strTEMP_DATA)
rBuffer.Clear(rBuffer, 0, rBufferSize)
lSocket.BeginReceive(rBuffer, 0, rBufferSize, SocketFlags.None, New
AsyncCallback(AddressOf Me.LocalDataArrivalEvent), lSocket)
Else
RaiseEvent DisConnect() 'peer closed connection
End If
Exit Sub
Catch
RaiseEvent DisConnect()
End Try
End Sub
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O7*************@tk2msftngp13.phx.gbl...
Martin,
It sounds like your string has an embedded null char in it
(Char.MinValue). Although it is perfectly valid for a String to contain a null char, the
Debugger treats it as a string terminator so it stops displaying it.
Without the closing quote I CANNOT concat strings. The string is valid to .NET and you can concatenate other strings to it!
However with the null char, the debugger and System.Console and some for
the Windows Forms functions will not work as expected as they rely on Win32
calls which treat the null char as a string terminator.
How can I correct this?
What does your rBuffer look like, are you certain it only has valid ASCII
characters in it? Is the data in the buffer shorter then the length of the
buffer? In other woreds is there trailing zeros in the byte array?
Hope this helps
Jay
"Martin Fletcher" <Ma*************@msn.com> wrote in message
news:vr************@corp.supernews.com... when I execute
dim strTEMP_DATA as string
strTEMP_DATA = Encoding.ASCII.GetString(rBuffer).ToString
I alway get a string without the closing quote. I see this in the
'Autos' window, I also see it when I hoover my mouse over the strTEMP_DATA
above.
An example would be:
It looks like "test
I believe it should look like "test"
Without the closing quote I CANNOT concat strings.
How can I correct this?