473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

C# Telnet echo off/on

Hi guys,

I am rewriting an old telnet server of mine from VB6 to C#. I do not have access to VB6 any more, so I cannot (nor do I really want to) use VB6 references.

Everything is working well, except for one problem I am having with setting the local echo off or on (for password entry).

In VB6, I used to send

Chr(255) & Chr(251) & Chr(1)

to turn echo off, and

Chr(255) & Chr(252) & Chr(1)

to turn it on.

This worked as expected on the old program, however I have tried various methods to send the same sequence under C#, but it's not working.

I have tried:

(char)255 ...
Convert.ToChar(255) ...
Encoding.GetEncoding(<1252/ASCII/UTF8>).GetString(new byte[] { 255 }) ...

None of these sequences seem to actually work. Any ideas?
May 7 '09 #1
4 6385
Plater
7,872 Expert 4TB
So whatever device you are talking to is supposed to respond that series of characters by either turning on or off the character echo?
May 7 '09 #2
Yes. It turns off local echo on or off on the connecting telnet clients. The problem is that I cannot seem to get C# to encode the char sequence in the same way that VB6 did with the Chr() function.
May 7 '09 #3
Ok, I have found the answer. The problem was that I was sending it via a Streamwriter, which fargles the output. By converting to bytes and sending directly to the socket, it works as it should - e.g.

byte[] cmd = new byte[] { 0xFF, 0xFB, 0x01 };
this.socket.Send(cmd);

correctly disables local echo on the connecting telnet client - in case anyone in the future needs this info. :)
May 8 '09 #4
Plater
7,872 Expert 4TB
Yeah a streamwriter is generally considered for text, and those bytes are not (ansi-ascii) characters.
May 8 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robert PADOVANO | last post by:
Hello, I wish to establish a connection in language PHP on a UNIX server by telnet. In fact, I would like : - Connect to server by sending IP adress, login, password - Send an order (example:...
5
by: G520 | last post by:
Hi I have been getting statistical rapports from a machine via a telnet server. Until now it has been done manually. However I want to automate the proccess, and scedule a PHP script to run...
3
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function...
4
by: Donnal Walter | last post by:
On Windows XP I am able to connect to a remote telnet server from the command prompt using: telnet nnn.nnn.nnn.nnn 23 where nnn.nnn.nnn.nnn is the IP address of the host. But using telnetlib,...
6
by: Donnal Walter | last post by:
Several months ago I tried using the telnet module (on Windows XP) to communicate with a proprietary host on our network. This was unsuccessful due to problems with "option negotiation", and I gave...
2
by: Howard | last post by:
Hello everyone, i was wondering if anybody knew how to "telnet" to another machine to get a file, but the machine that i am using and the machine i am targetting both do not have the telnet...
2
by: thilandeneth | last post by:
i need to do telnet via a web server please give me a idia to initiate the project following requirements are needed 1 Create web based custom telnet client to communicate with remote...
2
by: b00x | last post by:
Hi, I'm trying to develop a script that I can reuse to run remote commands on multiple UNIX servers via telnet. I've tried various php scripts after googling for a good 5 or so hours, but found...
3
by: =?Utf-8?B?cGlja2VkYW5hbWU=?= | last post by:
Hi, I am trying to establish a telnet session to do screen scraping. This device returns some custom escape sequences, which I can ignore, and some standard escape seq's. At your suggestion, I...
1
by: Samuel | last post by:
Hi, I am trying to automate a telnet session (currently using Python's telnetlib) and would like to echo any response of the remote host to stdout, as soon as it arrives on telnetlib's open TCP...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.