Get the listing of everyone logged on : Utilities « Network Protocol « Java

Get the listing of everyone logged on


import java.applet.Applet;
import java.awt.Button;
import java.awt.Font;
import java.awt.Frame;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Who {
    public static void main(String []v){
    Socket s = null;
    PrintWriter out = null;
    BufferedReader in = null;
    try {
      // Connect to port 79 (the standard finger port) on the host.
      String hostname = "";
      s = new Socket(hostname, 79);
      // Set up the streams
      out = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
      in = new BufferedReader(new InputStreamReader(s.getInputStream()));

      // Send a blank line to the finger server, telling it that we want
      // a listing of everyone logged on instead of information about an
      // individual user.
      out.flush(); // Send it out

      // Now read the server's response
      // The server should send lines terminated with \n or \r.
      String line;
      while ((line = in.readLine()) != null) {
      System.out.println("Who's Logged On: " + hostname);
    } catch (IOException e) {
      System.out.println("Who's Logged On: Error");
    // Close the streams!
    finally {
      try {
      } catch (Exception e) {

Related examples in the same category

1.A class that encodes URL parameter values for MIDP devices.
2.Scan your computer for ports in useScan your computer for ports in use
3.Using the URL Class (
4.TCP socket monitor
5.Create Socket helper
6.Implements a TCP/IP bounce utility (proxy)
7.URL utilities class that makes it easy to create new URLs based off of old URLs without having to assemble or parse them yourself
8.Download from URL
9.URL ParserURL Parser
10.A simple class to load an URL in a browser
11.Using the java API URL class, extract the http/https hostname.
12.Utility class for URL decoding.
13.Utility class for URL encoding.
14.Allows easy downloading of files from HTTP sites
15.enum Http Status