[ zvjezdana @ 26.05.2005. 09:58 ] @
Treba mi metoda koja moze da izracuna brzinu konekcije izmedju servera i klienta. Protokol je TCP, jezik JAVA. Treba mi nesto poput PING metode, samo u javi. |
[ zvjezdana @ 26.05.2005. 09:58 ] @
[ glock @ 26.05.2005. 17:14 ] @
nisam siguran al vidi biblioteku http://www.xbill.org/dnsjava/
[ me-tuzalem @ 26.05.2005. 17:29 ] @
Moglo bi možda ovako:
Code: public class Server{ public void main(String args[]){ try{ ServerSocket ss = new ServerSocket(9999); byte b[] = new byte[64*1024*1024]; while(true){ Socket s = ss.accept(); InputStream in = s.getInputStream(); long time = System.currentTymeMills(); int i = in.read(b); time = System.currentTimeMills() - time; s.close(); System.out.println("Data Rate : " + ((i/(1024*1024))/time) + " Mega Bytes Per Second" ); } }catch(Exception e){ e.printStackTrace(); } } } public class Client{ public static void main(String args[]){ try{ byte b[] = new byte[64*1024*1024]; Socket s = new Socket("IP", 9999); OutputStream out = s.getOutputStream(); long time = System.currentTimeMills(); out.write(b); time = System.currentTimeMills() - time; out.close(); s.close(); System.out.println("Data Rate : " + ((b.length/(1024*1024))/time) + " Mega Bytes Per Second" ); } catch(Exception e){ e.printStackTrace(); } } } Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|