0

I created a simple server program and connects a client to it using terminal. In the terminal window, the command telnet localhost [port number] was used. Can anyone please tell me how this command works?

Suppose i create a server via one terminal window, and can i connect a client to it using another terminal window opened in another computer, connected to internet through another router? Please tell me. Thanks in advance.

1 Answer 1

2

localhost is just a name for the local host. If you look into /etc/hosts you will find a line

127.0.0.1   localhost

Connections to localhost don't use the real network - you won't see anything on the wire from them.

If you want to connect to your server from another machine on your network, you must know the IP address of your server (you can get it with ip address show) (e.g. 192.168.13.45) and then type telnet 192.168.13.45 [portnumber].

4
  • Thanx, @guntbert I had the same question ,, well is there any way to send the request(telnet ) from any specific port number??
    – lazarus
    Nov 8, 2014 at 8:26
  • Why would you need that? Usually the client uses a (random) port number for the outgoing request, and the server doesn't care about it.
    – guntbert
    Nov 8, 2014 at 12:21
  • can you please refer to my question askubuntu.com/questions/547105/…
    – lazarus
    Nov 8, 2014 at 13:09
  • 1
    also see stackoverflow.com/questions/37551662/…
    – jouell
    Jan 7, 2022 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .