🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #808

Re: Czas serwera

#808
From: Artur Tyloch
Date: Thu, 31 Jul 1997 12:58
73 lines
2356 bytes
Artur Tyloch wrote:

> > : >Jak za pomoca skryptu JavaScript albo jakiegos appletu wprowadzic na
> > : strone
> > : >czas lokalny, jaki jest na serwerze, nie u uzytkownika, ktory strone
> > Jezeli server jest przyzwoity (unix lub NT z bajerami) to mozesz z appleta
> > polaczyc sie z serverem na ktorys port (sprawdz w services) i odczytac
Tak ten warunek musi byc spelniony!

> Jest to usluga DTime  Ta usluga
> umozliwia sprawdzenie aktualnego czasu i daty na dowolnym komputerze z ktorym
> sie polaczylismy (moze to byc nasz serwer). Port: 13. Portokol: w
> dokumencie rfc867.
A tak to wyglada:
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class DTimeApplet extends Applet
{
	String Time;
	public DTimeApplet()
	{
		String s = null;
		StringBuffer sb = new StringBuffer();
		try 
		{
			Socket socket = new Socket("friko.onet.pl",13);
			DataInputStream dis = new DataInputStream(socket.getInputStream());
			s = dis.readLine();
			Time=new String(s);
			socket.close();
		} 
		catch(IOException e)
		{
			Time = new String("Blad");
		}
	}
	
	public void paint(Graphics g)
	{
		g.drawString("Czas na friko.onet.pl:"+Time, 10, 20);
	}

	public void init()
	{
    	resize(320, 240);
	}
	
	public String getAppletInfo()
	{
		return "Name: DTimeApplet\r\n" +
		       "Author: Artur Tyloch\r\n";
	}	
}



I w HTML cosik takiego
<applet
    code=DTimeApplet.class
    name=DTimeApplet
    width=320
    height=240 >
</applet>
.....i voila.

Artur Tyloch

P.S.

bez P.S.
Technical Details
Message-ID: <33E08BBC.7E63@friko.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!ict.pwr.wroc.pl!not-for-mail
References: <01bc9b5e$c308dba0$LocalHost@k3.domnet.com.pl.domnet.com.pl> <33df9e7d.5988691@news.nask.org.pl> <01bc9d86$913e9ef0$0390c110@grat> <5rpp7d$i1o$1@sunrise.pg.gda.pl> <33E08139.9B6@friko.onet.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!agh.edu.pl!ict.pwr.wroc.pl!not-for-mail
From: Artur Tyloch <arturt@friko.onet.pl>
Newsgroups: pl.comp.lang.java
Subject: Re: Czas serwera
Date: Thu, 31 Jul 1997 14:58:53 +0200
Organization: Technical University of Wroclaw, Poland
Lines: 73
Message-ID: <33E08BBC.7E63@friko.onet.pl>
References: <01bc9b5e$c308dba0$LocalHost@k3.domnet.com.pl.domnet.com.pl> <33df9e7d.5988691@news.nask.org.pl> <01bc9d86$913e9ef0$0390c110@grat> <5rpp7d$i1o$1@sunrise.pg.gda.pl> <33E08139.9B6@friko.onet.pl>
Reply-To: arturt@friko.onet.pl
NNTP-Posting-Host: pppa143.poznan.tpnet.pl
Mime-Version: 1.0
X-Mailer: Mozilla 3.01Gold (Win95; I)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit