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();
}
}
}