473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Telnet Using C#

I need help coming up with a way to create a c# program to help me
Telnet to a hostIP.. Any suggestions.. or a way to start..

Aug 3 '06 #1
3 6690
You want SOCKETS
System.Net namespace I think.

Telnet (to my understanding) is just a connection.
So if you check out TCP sockets in MSDN you should get all the answers
you need.

Aug 3 '06 #2
A *full* implementation of a telnet client (with complete vt100
terminal emulation, for example) is a serious undertaking. However, the
most important part--typing text to the server, and having it send text
back to you--is about a 5-minute programming project for someone
familiar with sockets, and is a reasonably simple "my first sockets
program" sort of project.

In concept it's extremely easy: just connect on TCP port 23 to the
machine you're after, send what you type over the socket, and display
everything you receive on the screen. General-purpose network utilities
like "netcat" can act as a telnet client in a pinch.

System.Net.Sock ets has what you're after (the "Socket" class).
Unfortunately, in order to get a satisfactory user experience, you have
to listen for both keyboard and remote network input at the same time,
and the .NET sockets implementation uses a slightly more complicated
system of callbacks instead of events for asynchronous operation.

You've got a few options. The easiest is "polling" -- that is, using a
timer to check at regular intervals to see if data is waiting on the
network. This is very inefficient and leads to a sluggish interface.

You could create two threads, your primary one responds to user
interface events and sends data over the socket when needed. The
secondary one waits for data inbound over the network and displays it
to the screen. Better, but not optimal.

The final and best option is to just suck it up and learn how to
properly do asynchronous (i.e. thread pool based) programming with .NET
using BeginReceive() and EndReceive(), BeginSend() and EndSend(), etc.

Bear in mind that the last two options involve multithreading and lead
to a situation where the thread that receives data off the network is
NOT the thread that controls the user interface. If you're building a
console-based project, this isn't an issue, but windows (forms,
buttons, etc.) are only allowed to have one thread interact with their
UI components, and that thread has to be the primary user interface
thread. What saves you is that Control implements the
ISynchronizeInv oke interface, allowing you to call Invoke() or
BeginInvoke() on any control or form delegate and transfer control to
the correct thread.

But that's all a bit down the road for you. First things first:
Sockets.
jt******@gmail. com wrote:
I need help coming up with a way to create a c# program to help me
Telnet to a hostIP.. Any suggestions.. or a way to start..
Aug 4 '06 #3
On Fri, 04 Aug 2006 05:56:42 +0800, <jt******@gmail .comwrote:
I need help coming up with a way to create a c# program to help me
Telnet to a hostIP.. Any suggestions.. or a way to start..

Take a look at the System.Net.Sock ets.TcpClient class, it should allow you
to do everything you want as long as you dont need terminal emulation.

- Mark
Aug 4 '06 #4

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

Similar topics

2
50332
by: Dan | last post by:
I'm writing a simplistic telnet client in VB6 and I've run into a small snag. The program has a textbox to write in the string to be sent using ..SendData and has another textbox that displays what that server sends. When I first connect to the server (in this case, my university's smtp server), I get a response that the server acknowledges my connection. When I type something into the textbox and send it, however, I get no response...
1
3839
by: kumar | last post by:
Hi all, I want to write a telnet server for an embedded linux box using python.The problem is that it doesn't give a shell ( just a limited CLI commands for configuring it . )My requirement is to write a telnet server ( residing on the box) listening on some specific port where it can listen to telnet requests from clients and provide them an interactive command line session. I tried using the python's async_chat module but it is very...
4
11190
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, this code returns the traceback that follows: import telnetlib host = 'nnn.nnn.nnn.nnn'
6
5226
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 up on the project for a while. I still have need for this, however, so I recently started thinking about alternatives. I suppose I could dig deep enough into option negotiation to use the socket module (with telnet as a guide), but I am hoping...
2
8279
by: john brown | last post by:
I'm telnetting into a router. Apart from the fact I can't seem to view the output when iniciating the session, I can't match one of the expressions using Net::Telnet. I can telnet into the router manually without a problem. I'm running a sniffer at the same time just to see what's happening behind the scenes. The computer does an ARP request looking for the router's direction, but that seems to be it. I don't think any data actually...
5
5871
by: richardtinkler | last post by:
I need to communicate with a POP3 server using ASP. Does anybody have any ideas how I can set up a telnet connection using an ASP script? There are some components out there, but my host won't allow them. Thanks for any ideas, R
2
4592
by: eight02645999 | last post by:
hi i am using a telnet session to simulate an authentication mechanism USER = "user" PASSWORD = "password" try: telnet = telnetlib.Telnet(HOST) telnet.set_debuglevel(5) telnet.read_until("login: ") telnet.write(USER + "\n") telnet.read_until("Password: ")
2
2995
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>)
6
5513
by: sherrygomindes | last post by:
Hi I have written a perl script using the Telnet module. I need to remotely login in from one windows XP machine to another XP machine. But i get errors which i can't figure out the reason. Please someone help me its very very urgent. here is my code: #!/usr/bin/perl -w
17
7348
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9975
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...
1
9909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9788
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8794
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
7342
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
5241
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...
1
3889
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
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.