Re: How to debug this?
- From: "Brett" <no@xxxxxxxx>
- Date: Thu, 31 Mar 2005 00:40:21 -0500
"MeltingPoint" <none@xxxxxxx> wrote in message
news:rdGdnYSxfdhtH9bfRVn-3w@xxxxxxxxxxxxx
> "Brett" <no@xxxxxxxx> wrote in
> news:ubaN0QaNFHA.3844@xxxxxxxxxxxxxxxxxxxx:
>
>>
>> "MeltingPoint" <none@xxxxxxx> wrote in message
>> news:_s6dnStYC5jC9tbfRVn-jg@xxxxxxxxxxxxx
>>> "Brett" <no@xxxxxxxx> wrote in
>>> news:eWx8RjZNFHA.1096@xxxxxxxxxxxxxxxxxxxx:
>>>
>>>> For some reason when I step into the code below, it jumps out on the
>>>> second iteration at the line I have marked below. Nothing else
>>>> happens - no errors.
>>>>
>>>> Dim tcpClient As New System.Net.Sockets.TcpClient
>>>> tcpClient.Connect("127.0.0.1", 9005)
>>>>
>>>> While True
>>>> Dim networkStream As NetworkStream =
>>>> tcpClient.GetStream()
>>>>
>>>> 'If networkStream.CanWrite And networkStream.CanRead
>>>> Then
>>>>
>>>> ' Do a simple write.
>>>> Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is
>>>> anybody
>>>> there")
>>>> networkStream.Write(sendBytes, 0, sendBytes.Length)
>>>> ' Read the NetworkStream into a byte buffer.
>>>> Dim bytes(tcpClient.ReceiveBufferSize) As Byte
>>>> networkStream.Read(bytes, 0,
>>>> CInt(tcpClient.ReceiveBufferSize)) ' Output the data
>>>> received from the host to the console. Dim returndata As
>>>> String = Encoding.ASCII.GetString(bytes)
>>>>
>>>>
>>>>
>>>> Step into jumps out at above line. The rest of the code follows:
>>>>
>>>> Console.WriteLine(("Host returned: " + returndata))
>>>>
>>>> ' pause so user can view the console output
>>>> Console.ReadLine()
>>>> End While
>>>>
>>>> tcpClient.Close()
>>>>
>>>> There is a server version of the app that is sending data. Any
>>>> suggestions on how I can trace this down?
>>>>
>>>> Thanks,
>>>> Brett
>>>>
>>>>
>>>>
>>>
>>> Not sure what you mean, 'jumps out'. Does that mean it throws an
>>> exception? You can't 'step into' GetString() but I don't think thats
>>> what you mean.
>>>
>>> A quick solution would be to use DataAvailable:
>>>
>>> If networkStream.DataAvailable() Then
>>> networkStream.Read(...)
>>> End If
>>>
>>> OR the dangerous way...
>>>
>>> Do
>>> Loop Until networkStream.DataAvailable()
>>>
>>> too see if anything ever comes. (maybe put a counter in there and
>>> exit after a couple hundred loops :)
>>>
>>> but i think your trying to read to soon, if you wait on
>>> DataAvailable, all should work code wise.
>>>
>>> MP
>>
>> Very nice. The
>>
>> If networkStream.DataAvailable() Then
>> networkStream.Read(...)
>> End If
>>
>> code is working fine. I have a general question about the byte
>> array. Sending/receiving data via the tcp/ip streams or file streams
>> always uses the byte array. Why can't a regular string be used? What
>> is so special about the byte array?
>>
>> Thanks,
>> Brett
>>
>>
>>
>
> I would say it mostly has to do with unicode. One byte characters
> just don't do it on the global scale. By making you use
> Encoding.ASCII/UTF8/UTF7/Unicode.GetString/GetBytes Microsoft is reminding
> you of which market your targeting/omitting.
>
> A little blurp:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclasstopic.asp
>
> MP
Back to the application, what does it mean if I get this in my output window
everytime the app loads:
'DefaultDomain': Loaded
'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols
loaded.
'client': Loaded 'C:\Inetpub\VB.NET\client\bin\client.exe', Symbols loaded.
'client.exe': Loaded
'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll',
No symbols loaded.
'client.exe': Loaded
'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No
symbols loaded.
'client.exe': Loaded
'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll',
No symbols loaded.
'client.exe': Loaded
'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll',
No symbols loaded.
'client.exe': Loaded
'c:\windows\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualbasic.dll',
No symbols loaded.
The app seems to run fine despite the "No symbols loaded" lines.
Thanks,
Brett
.
- Follow-Ups:
- Re: How to debug this?
- From: Stephany Young
- Re: How to debug this?
- References:
- How to debug this?
- From: Brett
- Re: How to debug this?
- From: MeltingPoint
- Re: How to debug this?
- From: Brett
- Re: How to debug this?
- From: MeltingPoint
- How to debug this?
- Prev by Date: Re: IO function in Vb.Net slower than in Vb6.0
- Next by Date: Re: XML Schema
- Previous by thread: Re: How to debug this?
- Next by thread: Re: How to debug this?
- Index(es):
Relevant Pages
|
Loading