473,799 Members | 3,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Telnet: Grabbing Bytes Previously Written During Next Read?

Hi.

I am building a custom telnet interface and my problem is that I
want to read the user input along with the previously written stream.

Right now I am logging the user.

I have

Login: Bill

Login is written by:

buffer = ASCII.GetBytes( "Login: ");
_clientStream.W rite(buffer, 0, buffer.Length);

Bill is entered by the user.

At the next return, I want to read:

"Login: Bill".

This is how I know its a Login read
and not a Password: read.

I am reading input with the following loop:

Code:
while (true)
{

_bytesRead = 0;
try
{
//blocks until a client sends a message
_bytesRead = _clientStream.R ead(message,
0,4096); //message

}
catch
{
//a socket error has occured
break;
}

if (_bytesRead == 0)
{
break;
}

statusMessage += ASCII.GetString (message, 0,
_bytesRead);
But, my problem is that I get:

"Bill".

when the user submits his string.

How do I get both the written "Login: " and
the read "Bill" on the same read?

Please let me know if i need to provide more information,
otherwsie, thanks a lot for your response!
Jan 16 '08
22 1880
On Thu, 17 Jan 2008 09:01:31 -0800, pbd22 <du*****@gmail. comwrote:
Thanks Pete.

I am getting there thanks to your help.
Glad it's working out. You're welcome.
I have some nick-knacks that are, it seems,
not that trivial.

1) how do I highlight a line?
2) how do I change background color?
3) how do I change font color?
4) how do I clear the screen (aka. DOS "cls");
These are all new questions, and deserve an all-new thread.

Hint: when you repost those questions, you should be clear about how you
are displaying the text. There's a huge difference between doing those
kinds of things in a console window and doing them in a normal Forms
application window. For the former, see the Console class (it has
properties for setting font foreground and background, and a method for
clearing). For the latter, you can use a RichTextBox as a quick-and-dirty
implementation, or you can handle all of the drawing yoursself (more
complicated, but gives you more control and in the context of something
like this where the text is constantly changing, generally will provide
better visual quality and performance).

It may be you can get started with the above information. If you need
more help, start a new thread with specific questions.

Pete
Jan 17 '08 #21
OK, good point. I'll start another thread.

Thanks a ton Pete for your help!

Peter
Jan 17 '08 #22
4) how do I clear the screen (aka. DOS "cls");

Aha, another one missing chr$(12)... in this case its some <esc>[2J or
something... who knows, who cares
what do I know... anyone seen chr$(12)
//CY
Jan 26 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8664
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 seems to freeze after a couple of command. I did a simplify script that reproduce the problem each time (I'm using 2.3.4 on W2K):
7
14102
by: Rex Winn | last post by:
I've Googled until my eyes hurt looking for a way to issue Telnet commands from C# and cannot find anything but $300 libraries that encapsulate it for you. I don't want to be able to create a Telnet client. I just need to send a telnet request to a local IP address on a LAN issue a "c" then a "b" and stream back the text for internal use. The "c" changes sub-menus and the "b" is a switch to dump the status of a firewall. I need to issue...
0
3860
by: goroth | last post by:
I am trying to create a telnet client that will connect to several of my network devices on campus and change settings on the devices. So far I can connect with the code below, but I can't seem to get the correct return data from the device. Sometimes I get about 100 bytes and other times I get 3000 bytes. I even put a thread sleep but that still give me different return data from different devices. I know I am going to have to use an...
4
2958
by: Patricia Mindanao | last post by:
I want to call cgi perl scripts on my web hosters server from my HTML web pages (on the the web hosters server too). It occurs sometimes (especially during development phase) that these cgi-perl scripts didn't work like intended. They crash because e.g. - syntax errors - wrong or changing pathes - unexpected user input - ...
1
2109
by: Jia Lu | last post by:
Hello I have a program that can telnet to a host. But I cannot understand from part, can anyone explain it to me? Thank you very much. import sys, posix, time
6
6156
by: =?Utf-8?B?U2hhcmllZg==?= | last post by:
Dear All, I must write a client program in C# which will communicate with a switch throught telnet. When I create a socket connection on port 22, the switch responds with some text and at the end with some unreadable characters. I found out that the operating system of the switch is redhat and the protocol = SSH-2.0-openssh_3.9p1. My problem:
0
191
by: pbd22 | last post by:
Hi. I have Login: Bill Login is written by my program. Bill is entered by the user. At the next return, I want to read:
2
2998
by: thamayanthi | last post by:
Hi, The below code is used to connect to the remote machine using Telnet module in perl. use Net::Telnet; use Net::Ping; $telnet = new Net::Telnet (Timeout=>10,Errmode=>'die'); open (FILE,"C:/start.txt") or die ("Unable to open start.txt"); while(<FILE>)
17
7349
by: ravimath | last post by:
Dear all, I have written following script to loin to router bu it is showing error. #!c:\Perl\bin; use strict; use warnings; my $hostname = 'REMOVED FOR YOUR PROTECTION'; my $password = 'REMOVED FOR YOUR PROTECTION';
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.