473,396 Members | 2,033 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,396 software developers and data experts.

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 6579
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.Sockets 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
ISynchronizeInvoke 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.Sockets.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
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...
1
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...
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: 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...
5
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...
2
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)...
2
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...
6
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....
17
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 =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.