AdobeStock_455007340

Creating A Telnet Gateway

A CFC that accepts text input and returns text responses can easily be made accessible via Telnet. This is what you’ll need to do:
1) Make a copy of /cfusionmx7/gateway/config/socket.cfg (name it telnet.cfg perhaps), and then edit the copy and change the port: port=23.
2) Create a new gateway instance of type “TCP/IP Socket”, give it a unique name, point it at the telnet.cfg config file, and at your CFC file.
3) Start the new gateway instance.
4) Use a Telnet client to connect to your ColdFusion server (specify DNS name or IP address).
That should do it.

13 responses to “Creating A Telnet Gateway”

  1. Yacoubean Avatar
    Yacoubean

    That’s pretty cool. I’m trying to think of an instance where it would be useful, but I guess that’s not always the point. 😉 I guess there could be cases were people are pretty limited in what tools they have available to them, and telnet is the perfect answer.

  2. Sean Corfield Avatar
    Sean Corfield

    I built a primitive debugger using this approach which I demo’d at the 2004 Fusebox conference. Essentially the onIncomingMessage() method just called evaluate() on anything typed in and returning the result as a string.
    The possibilities offered by the event gateways are just amazing!

  3. Jason Hung Avatar
    Jason Hung

    I’m looking to do something like this, except using the SSH protocol. I’m guessing I would need to find out how SSH encrypts communications, for a start.

  4. David Avatar
    David

    hi,please help me about how cfchart tag can been displayed in cfform? I want to write a poll application with richform.Thanks very much

  5. John Farrar Avatar
    John Farrar

    Is there a way we could use this for making a CVS tools for project management with CF? This would be a BIG advantage for open source projects done in CF!

  6. Sean Corfield Avatar
    Sean Corfield

    Jason, you would need a new event gateway, written in Java, that handles the SSH protocol.
    John, can you explain what you mean? Are you suggesting writing a CVS pserver entirely in CF?

  7. rob Avatar
    rob

    Jason,
    Should be easy. Look at some SSH libraries for Java. One thing to note.. like the telnet example or the SSH example gateways are async so if your expecting something like a real telnet client where you can make a request and get a request right back on the same connection then you dont want to use a gateway. Gateways are good for if you need to lets create a form allowing you to send commands to a telnet server where you dont care if you get a result passed back to you from the telnet server.

  8. Anuj Gakhar Avatar
    Anuj Gakhar

    Ben, Thats really cool. Rather very innovative idea I must say. Can be useful if some external systems need to interact with Coldfusion for just getting and receiveing some sort of text messages. Good stuff.

  9. tony shelton Avatar
    tony shelton

    can this be used to create a web-based method of obtaining results for running a script from a windows platform to a unix box? (i.e. can i send a command like "cd /wwwroot/folderB" and "ls" to obtain files in "folderB")

  10. Michael Ratner Avatar
    Michael Ratner

    Ben help! i need to connect to my aquariums electronic controller that sits on port 23 on an ip on my home network.
    with CF i want to automate logging in with the username and password prompts that come up and pass a simple command. For example C gives me the current temp, ph, etc of my tank.
    How can i pass the username, pw, command to the ip/port and pull the data returned into a variable to process???
    Thanks Guys?!!

  11. Mike Avatar
    Mike

    Is there anyway to initiate a socket connection from coldfusion?
    I have some devices that I want to have coldfusion log into and run some commands on but the only way to access them is through telnet.

  12. Ben Forta Avatar
    Ben Forta

    CF dos not have that built in, but you could call Java classes to do that.
    — Ben

Leave a Reply