Note that there are some explanatory texts on larger screens.

plurals
  1. POjava tcp program too slow(on the same computer)
    primarykey
    data
    text
    <p>So basically I am running 2 java application on my computer ad then after i transmit data i calculate speed of transmition over java tcp and speed is always around 7 MegaBits/second i was expecting something atleast 56mbits/second anyway here is the client application :</p> <pre><code> import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { System.out.println("Hello, World"); String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("127.0.0.1", 7); BufferedInputStream inFromServer = new BufferedInputStream(clientSocket.getInputStream()); double count=0; OutputStream socketOutputStream = clientSocket.getOutputStream(); String s = "012345678901234567\n"; byte[] bytes = s.getBytes(); final int BUFFER_SIZE = 65536; byte[] buffer = new byte[BUFFER_SIZE]; // socketOutputStream.write(bytes); // inFromServer.read(buffer); // modifiedSentence = new String(buffer); // System.out.println("FROM SERVER:" + modifiedSentence); socketOutputStream.write(bytes); long times=System.nanoTime() ; long temp=times;long temp2=times; while (true) { socketOutputStream.write(bytes); count++; socketOutputStream.flush(); if(count&gt;=100000){ break; } } times=System.nanoTime() ; System.out.println("time(ns) : " + (times-temp2)); double speed=(72*2*count)/(double)((times-temp2)*Math.pow(10,-9)); System.out.println("speed : " + speed/(1024*1024)); clientSocket.close(); } } </code></pre> <p>and here is the server code :</p> <pre><code>import java.io.*; import java.net.*; class TCPClient extends Thread { Socket clientSocket; public TCPClient(Socket socket) { super("KKMultiServerThread"); this.clientSocket = socket; } public void run() //throws Exception { System.out.println("Hello, World"); try { String modifiedSentence; BufferedOutputStream outToServer = new BufferedOutputStream(clientSocket.getOutputStream()); BufferedInputStream inFromServer = new BufferedInputStream(clientSocket.getInputStream()); double count=0; String s = "012345678901234567\n"; byte[] bytes = s.getBytes(); long times=System.nanoTime() ; long temp=times;long temp2=times; final int BUFFER_SIZE = 19; byte[] buffer = new byte[BUFFER_SIZE]; modifiedSentence = ""; while ((inFromServer.read(buffer))!=-1) { // outToServer.write(bytes); // outToServer.flush(); } System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } catch (UnknownHostException e) { System.err.println("Don't know about host: taranis."); System.exit(1); } catch (IOException e) { System.err.println("Couldn't get I/O for " + "the connection to: taranis."); System.exit(1); } } } </code></pre> <p>server code was adjusted not to write but only recieve and client to only send where through put is increased to 27Mbit/sec , but not 50Mbit/sec wich is half speed of ethernet , any help ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload