Home > Ask the Microsoft .Net Development Experts > C# Development Questions & Answers > Can I make a socket connection or override the connection to port 23 to use telnet?
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Can I make a socket connection or override the connection to port 23 to use telnet?

Mark Belles EXPERT RESPONSE FROM: Mark Belles

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 29 August 2004
I am currently attempting to develop a Windows app that will run video encoding processes on remote computers within a company network. Is there a way make a socket connection or override the connection to port 23 on the remote computers so that I can utilize telnet? I'm trying to avoid having to setup a TcpListener program to a free port on every computer I wish to run processes on. Thanks.

>
You should not attempt to bind another listening socket to a port and address that you know a well known service is already running. What you are discussing is called socket hijacking. It is sometimes possible for one socket to bind to an address even if another socket is already bound to a less specific interface and port. For example, if you created a socket and bound it to IPAddress.Any on port 5000, it would be possible for another socket to come along afterwards and bind to a more specific interface (ie. the nic's IP address or loopback address). Often times instead of binding to a specific interface developers will take the easier route and bind using the IPAddress.Any address. This is fine, however it is vulnerable to the socket hijacking technique described above. If you are curious about this, just fire up a web browser and do a quick Google search for "Socket Hijacking", and you should find some relevant information.

So in review, do not do this. Even if it works, it's considered rude and extremely bad practice. I have tried this myself to bind on port 23 with telnet running, and I had no success. I would assume such a well known service such as Telnet will be very well written and bind to specific interfaces to prevent such a technique from being possible.

There is absolutely no reason that you cannot choose an open port to use, and make this the default port for your application. Review the list of well known ports here, http://www.iana.org/assignments/port-numbers and find one that is free. There's no more overhead in using an open port than there is to try and steal one that is in use. Also consider the debugging and support issues that might arise when trying to deploy an application that knowningly violates the respected rules of internet programming.

Try and use a port number that falls between 49152 through 65535. Those are considered open for private use. If you want, you can register your application and port number with IANA so that other developers won't be tempted to use your port number!


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
C#
Top C# expert advice
Escape from mailto:
Can I run a .NET app without installing .NET runtime?
Opening a link with parameters to a new window
Is it possible to open a child form in modal type?
Painting in the non-client area
Global cases to the entire application
Validating the textbox entry for date format
Book on network programming with C#
Calling a secondary UserControl applet

C# programming language
Inside Visual Studio 2010
Mono 2.0 moves .NET apps to Linux - includes migration analyzer
LINQ beyond queries: Strong-typed refection
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
Visual Studio 2008 Learning Guide: C# 3.0
Simonyi firm to address divide between domain experts and developers
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005

C# Development
Top C# expert advice
Using LoadRunner for testing in .NET
Take care with InitializeComponent
GroupBox inheritance
Escape from mailto:
Windows Forms: Overriding the OnClosing method
Passing data between forms
Can I run a .NET app without installing .NET runtime?
Opening a link with parameters to a new window
Is it possible to open a child form in modal type?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
C#  (SearchWinDevelopment.com)
GLib  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts