Calling Web Service Using Curl With Telnet Connection
Last Updated :
08 Jul, 2022
Prerequisite: Telnet, Curl
Terminal Network as the name suggests is an application layer protocol used to connect with hosts (remote machines) over a TCP/IP network. It is based on a client-server architecture where the telnet client makes a connection with the telnet server and once the connection has been established the client (your computer) acts as a terminal allowing you to come with the host using your computer. All information that is being exchanged between telnet client and server is unencrypted, that's why SSH is being used today.
You can connect to the host using the command prompt on Windows or using a specified CLI in your OS. If you want to test the local web service over a telnet connection.
telnet localhost/remotehost 80
Here, the host is the IP address of the host and the port is the port number on which the service is running (80 for HTTP). But remember, Telnet only works on TCP Port. Alternatively, you can specify an IP address instead of a name.
To look up for IP address, you can type nslookup google.com in your command prompt.
CURL:
A curl is just a tool that can be integrated with telnet to transfer data between client and server using Telnet protocol. Remember it can even use other protocols such as HTTP, HTTPS, FTP, and FTPS for transferring data. Here I'll only talk about how we can use Curl with Telnet.
Now let's talk about how we can integrate curl with Telnet Connection.
When we use curl with telnet, we tell curl to fetch the telnet URL so that it can send whatever it reads on stdin to a remote server and output whatever the server sends.
To connect to your local HTTP server running on port 80, type the following command. Remember you might need to configure your firewall and check for the inbound rule of services as it might have been disabled, in that case, you won't be able to connect.
curl -v telnet://localhost:80
Here '-v' refer to verbose which provides a brief explanation of what goes well or what went wrong. For example, if you want to test whether www.google.com is responding on port 443(HTTPS).
curl -v telnet://www.google.com:443
You'll be connected successfully if the port is open for making a connection. To terminate the session, you can use Ctrl+ C. Try to connect to port 21 or 23. You'll get 'failed to connect' when the Google server has configured a firewall that restricts connection according to inbound and outbound rules. You can even configure your firewall and make new rules by going to the advanced setting of your Firewall. Therefore, it's a great tool for testing changes done in the firewall.
Similar Reads
Web Services - Definition, Working, Types, Applications Web Service is the set of rules or guidelines which enable communication among different applications via the World wide web (.i.e. the internet). Before web service, there were other technologies but some of them have dependencies such as EJB (enterprise java bean) which allows applications to comm
5 min read
Minimal Web Server Using Netcat Netcat is a networking utility that can be used to complete various tasks over TCP and UDP. It can be used to send TCP and UDP packets, also it can listen on the ports, specified for UDP and TCP. This utility is well-known for its versatility, as its application ranges from setting up simple chat se
7 min read
Process of Using CLI via a Telnet Session TELNET stands for Teletype Network. It is a type of protocol that enables one computer to connect to a local computer. It is a used as a standard TCP/IP protocol for virtual terminal service which is given by ISO. Computer which starts connection known as the local computer. Computer which is being
2 min read
Testing REST API with Postman and curl In the world of API testing, there are many tools available. Postman and cURL are two of the most popular tools for it. Let's look at how to use these tools for testing them. We will send some HTTP requests and explore the basic syntax for both of them in this article. The article focuses on using a
7 min read
How to call web services in HTML5 ? In this article, we will see how to call the Web Services in HTML5, along with knowing different methods for calling the web services & understand them through the examples. Web services in HTML5 are a set of open protocols and standards that allow data to be exchanged between different applicat
3 min read
Using netcat to send a UDP packet without binding Netcat, also known as nc, is a powerful networking tool used for various tasks, including sending data across networks using TCP or UDP protocols. It is a versatile tool with applications across network security, administration, and troubleshooting. This guide will specifically focus on using Netcat
9 min read
Create, Use, and Run Postman Collections Postman Collections are a powerful feature that enables users to organize and manage API testing and development. Collections consist of requests, which are APIs with a request and response format. In this article, we study the creation, utilization, and execution of Postman Collections with example
4 min read
How to Connect to Telnet Server from Node.js ? Connecting to a Telnet server from Node.js involves creating a client that can communicate using the Telnet protocol. Telnet is a protocol used to establish a connection to a remote host to execute commands and transfer data. In Node.js, you can use various packages to facilitate the connection to a
4 min read
Telnet Automation / Scripting Using Python Telnet is the short form of Teletype network, which is a client/server application that works based on the telnet protocol. Telnet service is associated with the well-known port number - 23. As Python supports socket programming, we can implement telnet services as well. In this article, we will lea
5 min read
Launch an HTTP Server with a Single Line of Python Code Python, with its built-in capabilities, offers a simple and effective way to do this. With just a single line of code, you can launch an HTTP server to serve files from your local directory. This feature can be incredibly handy for developers, educators, and anyone needing a quick and easy way to sh
2 min read