I am developing a server which detects a device and its connection speed . is there any way i can detect a client's connection speed through response headers ??

public class Server_X {

    static int count = 0;

    public static void main(String args[]) {

        Socket s = null;
        ServerSocket ss2 = null;
        System.out.println("Server Listening......");
        try {
            ss2 = new ServerSocket(4445); // can also use static final PORT_NUM , when defined

        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("Server error");

        }

        while (true) {
            try {
                s = ss2.accept();
                System.out.println("connection Established");
                ServerThread st = new ServerThread(s);
                count++;
                System.out.println("total connections :" + count);
                st.start();

            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Connection Error");

            }
        }

    }

}

class ServerThread extends Thread {

    static String uagent, uaccept;
    static String[] b;
    static String[] c;
    Server_X obj = new Server_X();
    String line = null;
    BufferedReader is = null;
    PrintWriter os = null;
    Socket s = null;

    public ServerThread(Socket s) {
        this.s = s;
    }

    public void run() {
        try {
            is = new BufferedReader(new InputStreamReader(s.getInputStream()));
            os = new PrintWriter(s.getOutputStream());

        } catch (IOException e) {
            System.out.println("IO error in server thread");
        }

        try {
            line = is.readLine();
            while (line.compareTo("QUIT") != 0) {

                os.println(line);
                os.flush();
           // System.out.println(line);

                line = is.readLine();
                b = line.split(":");
                if (b[0].equals("User-Agent")) {
                    uagent = b[1];
             //               System.out.println(uagent);

                }
                c = line.split(":");
                if (c[0].equals("Accept")) {
                    uaccept = c[1];
           // System.out.println(uaccept);

                }
                UAgentInfo detect = new UAgentInfo(uagent, uaccept);

            }

        } catch (IOException e) {

            line = this.getName(); //reused String line for getting thread name
            //System.out.println("IO Error/ Client "+line+" terminated abruptly");
        } catch (NullPointerException e) {
            line = this.getName(); //reused String line for getting thread name
            //System.out.println("Client "+line+" Closed");
        } finally {
            try {
                System.out.println("Connection Closing..");
                if (is != null) {
                    is.close();
                    //System.out.println(" Socket Input Stream Closed");
                }

                if (os != null) {
                    os.close();
                    //  System.out.println("Socket Out Closed");
                }
                if (s != null) {
                    s.close();
                    //System.out.println("Socket Closed");
                    obj.count--;
                    System.out.println("Toatal connections (after closing):" + obj.count);
                }

            } catch (IOException ie) {
                // System.out.println("Socket Close Error");
            }
        }//end finally
    }
}

I believe there is not.
The best you could do is to send/receive a known quantity of data and see how long it takes. By comparing a small quantity with a larger one you caould eliminate latency and fixed overheads to get an approximate actual speed at that instant.

What james said ^ , check out speedtest.net

Browsers won't send things like the connection speed of the system they run on to servers, period.
You're stuck guessing by analysing the browser type sent by the browser, which may or may not be specific to a type of device that's limited to a certain maximum speed (but of course you could always have a slower speed than the highest your device supports).

Not possible to detect internet speed from header.
you can use web development language to detect internet speed like PHP, JSP / Servlet, .Net etc....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.