Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Users' Connection/Internet Speed 1

Status
Not open for further replies.

Rexolio

Technical User
Aug 29, 2001
230
Does anyone have a script or know of a way that I can find the connection speed of my web site viewers? I have some reports that people generate into .pdf, but depending upon the connection speeds, it can take a little while sometimes. Was hoping I could return their connection speed, run that against a script that would return the number of records that their criteria has returned and then make a suggestion upon the speed of their connection on whether on not they should proceed in creating the pdf report or try to refine their criteria to make a smaller report for faster download time.

Am I just dreaming?! :)
 
I don't think it can be done. What you could do is to ask the user, and save the value into a cookie, or in a db if the user is registered, so you will have that information next time, and would only need to ask again if the cookie was deleted, or something _________________
Bixarrio
e = m * (c ^ 2)
 
Here's a crazy thought.. s-)

Could you turn the buffer off and time the delivery of, say a 250K page ??

LOL

ToddWW
 
Adding to my previously insane idea...

You may not be able to determine the exact download speed, because other traffic on your site will affect the download, but you should be able to time it and put the visitor in one of two categories.

56K Modem
Broadband / T1

Slap me if I'm way off here. X-)

ToddWW
 
Still foaming at the mouth....

Since you can't redirect with the buffer turned on, how about creating a dummy page with say 100K of blah..blah..blah..

Set the background to black, which the browser should render before any text, thus hiding the blah..blah..blah..

Then have an onLoad event handler that fires a JavaScript function to redirect. At the top of the blah..blah..blah.. page, something like this..

Code:
<%
dim start
start = Now
%>

And at the end..
Code:
<%
Session(&quot;downloadtime&quot;) = Now - start
%>

On the redirect page,
Code:
<%
Response.Write Session(&quot;downloadtime&quot;)
%>

Just for testing purposes of course..

ToddWW :)
 
The way to do it is to create a Java applet.
and a sample file from the server.

import java.applet.*;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Date;
public class bandwidth extends Applet
implements Runnable
{
public float getBandwidth()
{
try
{
try
{
URL url = new URL(getCodeBase(),&quot;sample.zzz?n=&quot; + Math.random());
try
{
float fresult;
fresult=0;
InputStream inputstream = url.openStream();
Date date = new Date();
byte abyte0[] = new byte[500];
int ibytes = inputstream.read(abyte0);
int j;
// Get start Time
long start = date.getTime();
for(j=ibytes; ibytes != -1; j+=ibytes)
{
ibytes = inputstream.read(abyte0);
}
j++;
inputstream.close();
Date date1 = new Date();
// Get End Time
long end = date1.getTime();
// Calculate Bytes per millisecond
if(end-start==0)
{
fresult = 1250;
}
else
{
fresult = j/(end-start);
// Get in seconds not ms
}
// Turn the results into bits per second
fresult = (float)Math.round(fresult*10F)/10F;
return fresult*8;
}
catch(IOException ioexception)
{
System.out.println(&quot;Error: &quot; + ioexception);
}
}
catch(MalformedURLException malformedurlexception)
{
System.out.println(&quot;Error: &quot; + malformedurlexception);
}
}
catch(SecurityException securityexception)
{
System.out.println(&quot;Error: &quot; + securityexception);
}
return -1F;
}
}

I tried everything and at the end of the day Java provided the solution.

This will do it. The accuracy depends upon the size of the zipped sample file.


Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top