telnet connection

i have to make a chat server that allows clients to log in through telnet, can anyone tell me how to use telnet in java
[126 byte] By [gaurav_xmla] at [2007-11-26 18:24:35]
# 1
Google.the apache commons net package has a telnet API
masijade.a at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 2

Are you really planning on implementing a telnetd in Java? I mean, you can - but that's not what you want a chat-server to do, really.

Most of the time, what you're really asking about is how to use Sockets in a multi-threaded environment. Or, for something that scales better go read about the java.nio package.

Grant

ggaineya at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 3

actually this is what i need to do and thats why i posted a query for knowing how to connect to telnet

Implement a simple multithreaded chat server using the TCP socket libraries on Unix/Linux.

Server specifications:

The server takes a single command-line argument that specifies the port number the server is using, i.e. chatserver 5555 . The server should be able to handle new connections and also handle data from a client. The chat server should:

刋maintain a dynamic list of connected clients and broadcast each message it receives to all the connected clients (except the sender itself).

刋Prompt the user to enter a name and append that name to each message sent from that user.

刋Inform all connected clients of a new client that has logged in and also of a client that has logged out (by sending a keyword such as ¨BYE〃 or ¨EXIT〃).

刋Respond to a clientˇs request for a list of connected clients. The client will issue a command LIST and the server should reply to that client with a list of connected clients.

Client specification:

A user will simply use ¨telnet〃 to access the chat server.

gaurav_xmla at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 4
i'm not getting this client specification stuff.
gaurav_xmla at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 5

OK - so your project is entirely server-side socket connections and threading. The "client requirement" is simply that you do not have to write a client - use telnet, because it's whole job is knowing how to open socket connections to a server:port and send text commands down the pipe.

Grant

ggaineya at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 6
so i need to monitor telnet and thats what i'm not getting how would i do that
gaurav_xmla at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 7

?

No, you don't need to "monitor" telnet - it's just the thing you use to talk to the server, just like AIM is the app you use to talk to to AOL's IM server.

You write your server, and start it up. It starts listening for incoming traffic on port 5555.

You run telnet: $ telnet mymachine 5555

Your server wakes up and spins off a thread to handle the connection. That worker writes "Login:" to the socket.

Running telnet, you see "Login:", and you enter a uid and hit enter.

Server reads the incoming uid, writes "Password:" to the socket.

At telnet, you see "Password:", and you enter one.

Server reads password, validates the uid/pwd pair, and writes "Welcome!" to the socket.

At telnet, you see "Welcome!".

At this point, you know that your client/server communication works.

Does that help any?

Grant

ggaineya at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 8
yup thanks
gaurav_xmla at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...
# 9
HI,I need to telnet to a unix server , and run some shell scripts there ..but although i can telnet how do i provide the userid /passwd during login to my remote unix server...can u plz help me wth the code..
profilemia at 2007-7-9 5:58:39 > top of Java-index,Core,Core APIs...