The telnet client is a simple commandline utility that is used to connect to socket servers and exchange text messages. Here is an example of how to use telnet to connect to google.com and fetch the homepage.
$ telnet google.com 80
The above command will connect to google.com on port 80.
$ telnet google.com 80
Trying 74.125.236.69...
Connected to google.com.
Escape character is '^]'.
Now that it is connected, the telnet command can take user input and send to the server, and whatever the server replies with, will be displayed on the terminal. For example send the http GET command and hit enter twice.
GET / HTTP/1.1
Sending the above will generate some response from the server. Now we are going to make a similar telnet program in python. The program is short and simple. To implement a program that takes user input and fetches results from the remote server at the same, requires somekind of parallel processing. Now the obvious solution to this is to use threads. One thread to keep receiving message from server and another to keep taking in user input. But there is another way to do this apart from threads. And that is select function. Select function allows to monitor multiple sockets/streams for readability...
Read full post here
Code a simple telnet client using sockets in python
$ telnet google.com 80
The above command will connect to google.com on port 80.
$ telnet google.com 80
Trying 74.125.236.69...
Connected to google.com.
Escape character is '^]'.
Now that it is connected, the telnet command can take user input and send to the server, and whatever the server replies with, will be displayed on the terminal. For example send the http GET command and hit enter twice.
GET / HTTP/1.1
Sending the above will generate some response from the server. Now we are going to make a similar telnet program in python. The program is short and simple. To implement a program that takes user input and fetches results from the remote server at the same, requires somekind of parallel processing. Now the obvious solution to this is to use threads. One thread to keep receiving message from server and another to keep taking in user input. But there is another way to do this apart from threads. And that is select function. Select function allows to monitor multiple sockets/streams for readability...
Read full post here
Code a simple telnet client using sockets in python