Search code examples
node.jsprotocolstelnet

Is possible to serve http from telnet server in node.js?


I understand that the Http protocol is different from the Telnet protocol. Both are a layer above the net module in node.js. So if I create a Telnet server chat application, does that mean I can't serve http to the browser? I want to have a web client that connects to the telnet chat server.

Is it possible to write two applications: one web server, and one telnet server. Then connect the web server to the telnet server? Would this be the logical way to create a web client for the telnet server?


Solution

  • To write a telnet chat app in node.js would require you to use raw sockets. (http://nodejs.org/api/net.html#net_class_net_socket)

    Http runs over TCP (sockets).

    Can you do both? Well, yes, but not exactly easily. The issue is both http and telnet would create the socket connection, but the telnet client wouldn't do anything else until told to, whereas http would send the http request.

    You could use the lack of the request for some period of time to be an indicator of telnet client, but the second issue is that it means you have to manually receive and reply for the http requests.