Re: How to debug this?




"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


.



Relevant Pages

  • Re: what does "->" and "=>" do?
    ... Ok brett its pretty simple the difference between the two. ... This is one of many ways to populate an array in php. ... $array['skinid'] refers to the value of $skinID. ...
    (comp.lang.php)
  • Re: question about matrix...?
    ... <SNIP> ... > doesn't your loop iterator tell you where you are in your array? ... Brett ...
    (comp.soft-sys.matlab)
  • Re: Cant assign value to structure in array?
    ... 'create space for new array element ... Brett ... > public int MyInt; ... > Now, this should not give you a compiler error, but it's definitely not ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to debug this?
    ... all should work code wise. ... >> always uses the byte array. ... > just don't do it on the global scale. ... Because they are the ones using 7 bit characters that are stored ...
    (microsoft.public.dotnet.languages.vb)
  • Re: question about matrix...?
    ... Brett Shoelson wrote: ... >>> on value 5 of the array ... to convert from tabular format into matrix format, ... and must then solve for the index of the second dimension. ...
    (comp.soft-sys.matlab)

Loading