I work for a telecom company. We need to get data from our 5ESS switches to be consumed by a .NET app. The data I am getting back is incomplete. For example, the beginning of the first line recvd from the device should read: SWT5 5e16(2) 02.00 Instead I get a bunch of gibberish then SWT5 The text greeting message that comes up above the login prompt gets cut up (some chars are dropped) followed by a (tab or LF) then the text greeting continues then cuts of a few chars again followed by another (tab or LF), etc.. The login prompt should be: login: But instead I get: a TAB char or TAB and n: Like a lot of examples, I am using TCPClient, incoming data into a byte array and displaying the string data in a textbox so I can see it. Dim responseData As [String] = [String].Empty data = New [Byte](2048) {} Dim bytes As Int32 = st.Read(data, 0, data.Length) responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes) txtRetVal.Text += responseData.ToString I have done this against UNIX applications in the past the same way without issue. Also, the switch will send some data, pause, then send more until I get the results I am expecting. It does not all happen at once. The login greeting/prompt will come in thirds in a normal telnet session. I cannot find any info anywhere that will help me here. I thought maybe I needed term emulation but then I will get a large block of the greeting message intact. If I needed emulation wouldn't it be consistant?
If it is any help, I was able to connect using Hyperterminal > ANSIW. XP's Telnet does well until I enter my first password charactor to log in, which I believe it sees as me submitting the password. Thanks [quoted text, click to view] "pickedaname" wrote: > I work for a telecom company. > We need to get data from our 5ESS switches to be consumed by a .NET app. > The data I am getting back is incomplete. > For example, the beginning of the first line recvd from the device should > read: > SWT5 5e16(2) 02.00 > > Instead I get > a bunch of gibberish then SWT5 > > The text greeting message that comes up above the login prompt > gets cut up (some chars are dropped) followed by a > (tab or LF) then the text greeting continues then cuts of a few chars again > followed by another (tab or LF), etc.. > > The login prompt should be: > login: > > But instead I get: > > a TAB char > > or > > TAB and n: > > Like a lot of examples, I am using TCPClient, incoming data into a byte array > and displaying the string data in a textbox so I can see it. > > Dim responseData As [String] = [String].Empty > data = New [Byte](2048) {} > Dim bytes As Int32 = st.Read(data, 0, data.Length) > responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes) > txtRetVal.Text += responseData.ToString > > I have done this against UNIX applications in the past the same way without > issue. > Also, the switch will send some data, pause, then send more until I get the > results I am expecting. > It does not all happen at once. The login greeting/prompt will come in > thirds in a normal telnet session. > I cannot find any info anywhere that will help me here. > I thought maybe I needed term emulation but then I will get a large block of > the greeting message intact. If I needed emulation wouldn't it be consistant?
Hi, My understanding of your issue is: You used TCPClient to retrieve data from your switches; however you found that the retrieved data was a bunch of gibberish, not as expected. You could get the correct information on your UNIX applications. If I have misunderstood, please let me know. For further research, I would like to know: 1. Did you log on the switch first and then retrieve the data? 2. What was the encoding format when your UNIX applications logged on your switch? 3. You couldn't use Telnet to retrieve data from switch due to logon failure, right? 4. If your application uses ANSI (System.Text.Encoding.Default) encoding, what's the result? Charles Wang Microsoft Online Community Support ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ======================================================
Hi Charles, What I am trying to do with the switch is establish a session, logon, run a status on a telephone number, capture the results as string(which would normally be displayed on a screen) and close the session. Once I have the status in an object, I can parse through and consume this data in .NET. When I try to connect via Hyperterminal using ANSIW encoding, it looks/works fine. When I change the properties of the hyperterminal connection to use just ANSI encoding, that also works fine. If ANSI is the default encoding for TCP connections in dot net, would setting the encoding make a difference, or is none applied unless you specify? Thanks, -Lance R. [quoted text, click to view] "Charles Wang[MSFT]" wrote: > Hi, > My understanding of your issue is: > You used TCPClient to retrieve data from your switches; however you found > that the retrieved data was a bunch of gibberish, not as expected. > You could get the correct information on your UNIX applications. > If I have misunderstood, please let me know. > > For further research, I would like to know: > 1. Did you log on the switch first and then retrieve the data? > 2. What was the encoding format when your UNIX applications logged on your > switch? > 3. You couldn't use Telnet to retrieve data from switch due to logon > failure, right? > 4. If your application uses ANSI (System.Text.Encoding.Default) encoding, > what's the result? > > Charles Wang > Microsoft Online Community Support > > ====================================================== > When responding to posts, please "Reply to Group" via > your newsreader so that others may learn and benefit > from this issue. > ====================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. > ====================================================== >
Dear Lance, UTF-8 is the default encoding in .NET platform; the Default is the encoding of system's current ANSI code page. TCPClient uses socket to send and receive messages. It's a channel used to send stream with no default encoding. The encoding depends on the messages. In other words, if the server uses the ANSI/ANSIW encoding to encode and decode messages, the client should explicitly specify ANSI as messages encoding when it sends or receives messages. So I recommend that you specify the ANSI encoding for sending and receiving messages. If you have any other questions, please feel free to let me know. It's my pleasure to be of assistance. Sincerely, Charles Wang Microsoft Online Community Support
Hi Charles, How do I specify this? [quoted text, click to view] "Charles Wang[MSFT]" wrote: > Dear Lance, > UTF-8 is the default encoding in .NET platform; the Default is the encoding > of system's current ANSI code page. TCPClient uses socket to send and > receive messages. It's a channel used to send stream with no default > encoding. The encoding depends on the messages. In other words, if the > server uses the ANSI/ANSIW encoding to encode and decode messages, the > client should explicitly specify ANSI as messages encoding when it sends or > receives messages. > > So I recommend that you specify the ANSI encoding for sending and receiving > messages. > > If you have any other questions, please feel free to let me know. It's my > pleasure to be of assistance. > > Sincerely, > Charles Wang > Microsoft Online Community Support > > > > > >
Dear Lance, I'm sorry that I should provide an example for you in my previous reply. Once you have used TCPClient to connect to the server. You can send messages to server like: Dim strMessage as String strMessage="Hi Lance!" client.Send(System.Text.Encoding.Default.GetBytes(strMessage)); You can receive messages like: Dim buffer As Byte() = New Byte(1024) {} Dim nRet As Integer = Me.client.Receive(buffer) Me.txtRecv.Text = System.Text.Encoding.Default.GetString(buffer) If you have any other questions or concerns, please feel free to let me know. It's my pleasure to be of assistance. Sincerely, Charles Wang Microsoft Online Community Support
Hi Charles, That's how I had it set up before. When I change the encoding to default, I get the same results as before. Any other ideas? Thanks. [quoted text, click to view] "Charles Wang[MSFT]" wrote: > Dear Lance, > I'm sorry that I should provide an example for you in my previous reply. > > Once you have used TCPClient to connect to the server. > You can send messages to server like: > Dim strMessage as String > strMessage="Hi Lance!" > client.Send(System.Text.Encoding.Default.GetBytes(strMessage)); > > You can receive messages like: > Dim buffer As Byte() = New Byte(1024) {} > Dim nRet As Integer = Me.client.Receive(buffer) > Me.txtRecv.Text = System.Text.Encoding.Default.GetString(buffer) > > If you have any other questions or concerns, please feel free to let me > know. It's my pleasure to be of assistance. > > Sincerely, > Charles Wang > Microsoft Online Community Support > > > >
Hi, For troubleshooting this issue, I would like that: 1. If it's convenient for you, please mail me (changliw@microsoft.com) your code snippet of the whole communication process. 2. You can use the monitor tool NetMon or Ethereal to monitor and compare the data sent by Hyperterminal, telnet command and your application. Sincerely, Charles Wang Microsoft Online Community Support
Don't see what you're looking for? Try a search.
|