import java.io.*;
import java.net.*; 
import java.awt.*;
import java.applet.Applet;

public class Counter extends Applet {

  static int count = 0; 
  Font font = new java.awt.Font("Helvetica", Font.BOLD, 24);    

  public void init() {

    URL url = getDocumentBase(); 
    System.out.println("Document Base: " + url);  
    System.out.println("Host" + url.getHost()); 

    try {
      Socket t = new Socket(url.getHost(), 8190); 
      DataInputStream in 
        = new DataInputStream(t.getInputStream()); 
      count = in.readInt(); 
    } catch (Exception e) { 
      System.out.println("Error: " + e); 
    }
  }

  public void paint(Graphics g) {
    int x = 0, y = font.getSize();
    g.setColor(Color.green);
    g.setFont(font);
    g.drawString("You are visitor: " + count, x, y); 
  }

}