Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:52:47+00:00 2026-05-26T08:52:47+00:00

I tested the performance of transferring data from a program to another over socket

  • 0

I tested the performance of transferring data from a program to another over socket on a single computer, and the speed is 120MBytes/s, is it normal?

My server and client programs are both extremely simple.

And my computer is AMD Athlon X2 4000+, 4G DDR2 667 ram, with windows xp sp3.

My friend said it was slow, and should be faster. But I don’t know how can I improve them, or is there any other libraries I can try to get a better speed?

UPDATE

The server and client programs were both on my own computer, a single computer. The network card will limit the speed or not?


Server.java

import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleServer {
    public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(6666);
        Socket socket = server.accept();
        OutputStream output = socket.getOutputStream();

        byte[] bytes = new byte[10 * 1024]; // 10K
        for (int i = 0; i < bytes.length; i++) { bytes[i] = 12; } // fill the bytes

        // send them again and again
        while (true) {
            output.write(bytes);
        }
    }
}

Client.java

public class SimpleClient {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 6666);
        InputStream input = socket.getInputStream();
        long total = 0;
        long start = System.currentTimeMillis();

        byte[] bytes = new byte[10240]; // 10K

        // read the data again and again
        while (true) {
            int read = input.read(bytes);
            total += read;
            long cost = System.currentTimeMillis() - start;
            if (cost > 0 && System.currentTimeMillis() % 1000 == 0) {
                 System.out.println("Read " + total + " bytes, speed: " + (total / (1024.0*1024)) / (cost / 1000.0) + " MB/s");
            }
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:52:47+00:00Added an answer on May 26, 2026 at 8:52 am

    Can you give me the output of this program?

    public class SimpleServer {
        public static void main(String[] args) throws Exception {
            ServerSocket server = new ServerSocket(6666);
            Socket socket = server.accept();
            OutputStream output = socket.getOutputStream();
    
            byte[] bytes = new byte[32*1024]; // 32K
            while (true) {
                output.write(bytes);
            }
        }
    }
    public class SimpleClient {
        public static void main(String[] args) throws Exception {
            Socket socket = new Socket("127.0.0.1", 6666);
            InputStream input = socket.getInputStream();
            long total = 0;
            long start = System.currentTimeMillis();
    
            byte[] bytes = new byte[32*1024]; // 32K
            for(int i=1;;i++) {
                int read = input.read(bytes);
                if (read < 0) break;
                total += read;
                if (i % 500000 == 0) {
                    long cost = System.currentTimeMillis() - start;
                    System.out.printf("Read %,d bytes, speed: %,d MB/s%n", total, total/cost/1000);
                }
            }
        }
    }
    

    on my machine prints

    Read 25,586,204,672 bytes, speed: 5,245 MB/s
    Read 53,219,426,304 bytes, speed: 5,317 MB/s
    Read 85,018,968,064 bytes, speed: 5,416 MB/s
    Read 117,786,968,064 bytes, speed: 5,476 MB/s
    

    Try sending 32K blocks many times (for at least 2 seconds) and you should get 400 MB/s or more. e.g. at least 10,000 times.

    On a very fast machine you can get 1 GB/s on a single client. With multiple clients you might get 8 GB/s.

    Here is an example

    Making file transfer more efficient Java


    If you have a 100 Mb card you can expect around 11 MB/s (bytes per second).

    Similarly for 1 Gb ethernet youc an expect around 110 MB/s

    For a 10 Gig-E ethernet you might get up to 1 GB/s however you might only get half this unles syour system is highly tuned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tested the performance of GServer by implementing the most basic server and checked
Has anyone ever tested, or does anyone know, the performance differences of these two
have not tested on windows. but in ubuntu when u disconnect from the network,
I'm new to computer coding and have just finished coding an app and tested
I have been investigating some performance issues with my database (SQL Server 2008). SQL
In our SQL Server 2005 database (tested using Management Studio with DBCC FREEPROCCACHE and
Should I prefer binary serialization over ascii / text serialization if performance is an
I just tested the H2 datastore (with Datanucleus 2.x) The performance is VERY slow.
everyone,recently i was debugging a program for improve performance.i notice a interest thing about
I have a web app that needs both functionality and performance tested, and part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.