socketserver - how to detect client's Internet speed from the response headers in java? -


i have server response headers through detect type of device. there way can internet speed through response headers or other method ?

server_x:

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 {              // can use static final port_num, when defined             ss2 = new serversocket(4445);          } 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");             }         }     } } 

serverthread:

class serverthread extends thread {      static string uagent, uaccept;     static string[] b;     static string[] c;     server_x obj = new server_x();     string line = null;     bufferedreader = null;     printwriter os = null;     socket s = null;      public serverthread(socket s) {         this.s = s;     }      public void run() {         try {             = 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 getting thread name             // system.out.println("io error/ client "+line+" terminated abruptly");         } catch (nullpointerexception e) {             line = this.getname(); // reused string line getting thread name             // system.out.println("client "+line+" closed");         } {             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     } } 

you didn't specify protocol server using; suppose http since you're catching "user-agent" , "accept". if i'm correct, there's no header information you're looking for, can check on https://en.wikipedia.org/wiki/list_of_http_header_fields.


Comments