473,378 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Detect connection speed

Usenet,

I am currently working on my website and am needing to detect the
connection speed of the client. I would like to do this in PHP and not
use any other languages. This makes it a bit more complicated. I know
it is possiable to do this in PHP but I can't think of how.

All I need to figure out is if they are on dial up or not. It doesn't
have to be 100% accurate but at least 50% accurate. Any help is greatly
appreciated.

Jordan

Jul 17 '05 #1
13 7404
In article <11**********************@f14g2000cwb.googlegroups .com>,
Jo*********@gmail.com wrote:
I am currently working on my website and am needing to detect the
connection speed of the client. I would like to do this in PHP and not
use any other languages. This makes it a bit more complicated. I know
it is possiable to do this in PHP but I can't think of how.

All I need to figure out is if they are on dial up or not. It doesn't
have to be 100% accurate but at least 50% accurate. Any help is greatly
appreciated.


Unless you setup some sort of client/server program where the client can
be downloaded to the client browser, run where it connects to the
server, then disconnects, I don't see a way to do this with PHP. Java,
yes. But not PHP.

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #2
If it doesn't have to be 100% accurate, why not just ask the user if
they're on broadband or dialup?

Jo*********@gmail.com wrote in news:1112656179.236197.282160
@f14g2000cwb.googlegroups.com:
Usenet,

I am currently working on my website and am needing to detect the
connection speed of the client. I would like to do this in PHP and not
use any other languages. This makes it a bit more complicated. I know
it is possiable to do this in PHP but I can't think of how.

All I need to figure out is if they are on dial up or not. It doesn't
have to be 100% accurate but at least 50% accurate. Any help is greatly
appreciated.

Jordan


Jul 17 '05 #3
Hi there,

Have you thought of javascript?

<script type="text/javascript">
counter = 0;
modemNeedsThisManyMiliseconds = 700;

tempImageOf100Kbs = new Image();
tempImageOf100Kbs.onload = function() { window.clearInterval(
milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
window.location.href = "broadband.html" : window.location.href =
"modem.html"}
milisecondCounter = window.setInterval( "counter++", 1 );
tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
</script>

The long line does all the job, and apart from looking ugly it works.
Of course you'll need to figure out the value of the
modemNeedsThisManyMiliseconds variable...

Also you may need to put some variable string in the image
(image.jpg?code=kdmkdfmsfsd) so that browser doesn't use cache!

I hope I gave you a hint in solving your problems...

- Evanescent Lurker -

Jul 17 '05 #4
ev***************@gmail.com napisa³:
Hi there,

Have you thought of javascript?

<script type="text/javascript">
counter = 0;
modemNeedsThisManyMiliseconds = 700;

tempImageOf100Kbs = new Image();
tempImageOf100Kbs.onload = function() { window.clearInterval(
milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
window.location.href = "broadband.html" : window.location.href =
"modem.html"}
milisecondCounter = window.setInterval( "counter++", 1 );
tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
</script>

The long line does all the job, and apart from looking ugly it works.
Of course you'll need to figure out the value of the
modemNeedsThisManyMiliseconds variable...

Also you may need to put some variable string in the image
(image.jpg?code=kdmkdfmsfsd) so that browser doesn't use cache!


And instead of loading broadand.html or modem.html you could just make a
form on the page
<FORM name='connform' method='post' blahblahblah>
<INPUT type='hidden' name='connection' value=''>
</FORM>

and

[pseudo-code]
document.forms.connform.connection='broadband'
(or document.forms.connform.connection='modem')
document.forms.connform.submit()
[/pseudo-code]

this way you can have the info on a single page.

Cheers
Mike
Jul 17 '05 #5
ev***************@gmail.com wrote:
Hi there,

Have you thought of javascript?

<script type="text/javascript">
counter = 0;
modemNeedsThisManyMiliseconds = 700;

tempImageOf100Kbs = new Image();
tempImageOf100Kbs.onload = function() { window.clearInterval(
milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
window.location.href = "broadband.html" : window.location.href =
"modem.html"}
milisecondCounter = window.setInterval( "counter++", 1 );
tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
</script>


Nice function! :-)
One 'but':
Be sure to run this function AFTER the page loaded, otherwise all other kind
of downloads can interfere with the speed,

Regards,
Erwin Moller

Jul 17 '05 #6
Or even simpler, he can replace:

window.location.href = "broadband.html" : window.location.href =
"modem.html"

with

window.location.href += "?speed=broadband" : window.location.href +=
"?speed=modem"

? can be replaced with & if needed... and fetch them with $_GET in php
:)

Also you must consider what Erwin Moller wrote... I've thought of it as
an empty page which redirects, hence only my code would be loaded, but
if you bundle it with everything else there is a problem...

Jul 17 '05 #7
ev***************@gmail.com (ev***************@gmail.com) wrote:
: Hi there,

: Have you thought of javascript?

: <script type="text/javascript">
: counter = 0;
: modemNeedsThisManyMiliseconds = 700;

: tempImageOf100Kbs = new Image();
: tempImageOf100Kbs.onload = function() { window.clearInterval(
: milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
: window.location.href = "broadband.html" : window.location.href =
: "modem.html"}
: milisecondCounter = window.setInterval( "counter++", 1 );
: tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
: </script>

: The long line does all the job, and apart from looking ugly it works.
: Of course you'll need to figure out the value of the
: modemNeedsThisManyMiliseconds variable...

I wonder how long it takes a 14.4 modem to download the 100Kbs image used
to test the speed of the connection.
--

This space not for rent.
Jul 17 '05 #8
Malcolm Dew-Jones napisa³:
ev***************@gmail.com (ev***************@gmail.com) wrote:
: Hi there,

: Have you thought of javascript?

: <script type="text/javascript">
: counter = 0;
: modemNeedsThisManyMiliseconds = 700;

: tempImageOf100Kbs = new Image();
: tempImageOf100Kbs.onload = function() {
: window.clearInterval(
: milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
: window.location.href = "broadband.html" : window.location.href =
: "modem.html"}
: milisecondCounter = window.setInterval( "counter++", 1 );
: tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
: </script>

: The long line does all the job, and apart from looking ugly it works.
: Of course you'll need to figure out the value of the
: modemNeedsThisManyMiliseconds variable...

I wonder how long it takes a 14.4 modem to download the 100Kbs image
used to test the speed of the connection.

Hmmmm... I guess you could always try and test it. :)
A 14.4 modem downloads 14.4 Kb per second, that means ~1.6 KBps, which
gives us 100 / 1.5 (not 1.6 - let's assume some overhead) = ~67s.
But test it anyway. :)

Cheers
Mike
Jul 17 '05 #9
=?ISO-8859-2?Q?Micha=B3_Wo=BCniak?= (mikiwoz_remove_this@yahoo_remove_this.co.uk) wrote:
: Malcolm Dew-Jones napisa³:

: > ev***************@gmail.com (ev***************@gmail.com) wrote:
: > : Hi there,
: >
: > : Have you thought of javascript?
: >
: > : <script type="text/javascript">
: > : counter = 0;
: > : modemNeedsThisManyMiliseconds = 700;
: >
: > : tempImageOf100Kbs = new Image();
: > : tempImageOf100Kbs.onload = function() {
: > : window.clearInterval(
: > : milisecondCounter ); ( counter < modemNeedsThisManyMiliseconds ) ?
: > : window.location.href = "broadband.html" : window.location.href =
: > : "modem.html"}
: > : milisecondCounter = window.setInterval( "counter++", 1 );
: > : tempImageOf100Kbs.src = "http://www.yoursite.com/image.jpg";
: > : </script>
: >
: > : The long line does all the job, and apart from looking ugly it works.
: > : Of course you'll need to figure out the value of the
: > : modemNeedsThisManyMiliseconds variable...
: >
: > I wonder how long it takes a 14.4 modem to download the 100Kbs image
: > used to test the speed of the connection.
: >
: Hmmmm... I guess you could always try and test it. :)

Oh dear do I have to?

: A 14.4 modem downloads 14.4 Kb per second, that means ~1.6 KBps, which
: gives us 100 / 1.5 (not 1.6 - let's assume some overhead) = ~67s.
: But test it anyway. :)

Oh look, I don't have to test it because some nice person has just made a
very reasonable looking ball park estimate - it could take around a
minute.

A 56 K modem might therefore take about 15 seconds (very rough estimate).

Actually you do need to test it because part of the modem's speed comes
from data conmpression, which works less well on pre-compressed data (i.e.
jpeg images), so the speed could be slower than estimated.

(And of course you should test it anyway - the above is just to check
whether the approach is reasonable enough to be worth testing.)

Personally I preferred the suggestion to ask the user for their
preferences. Imagine if everybody's home page started testing the
connection speed using this technique.

In some settings the javascript might be very useful, so this is not meant
to sound derogatory in any way, just things to think about before you use
it.
--

This space not for rent.
Jul 17 '05 #10
You can always use smaller image but the problem is that if the image
is too small, you won't get enough diffference, and if it is too large
(and 100kb IS) then the user will walk away to other URL... This is not
an efficient way of doing it. As far as I know there is no efficent
way. I just prvided posible solution that I have never used...

Or to put it another way, I posted this so we could brain storm my idea
and help someone along the way :) This code was never tested and should
never be put on the web in a copy-paste fashion. Use your had and then
use this code :)

Anyway, you can always put "Testing your newtwork speed... Please wait"
:-)

- Evanescent Lurker -

Jul 17 '05 #11
ev***************@gmail.com (ev***************@gmail.com) wrote:
: You can always use smaller image but the problem is that if the image
: is too small, you won't get enough diffference, and if it is too large
: (and 100kb IS) then the user will walk away to other URL... This is not
: an efficient way of doing it. As far as I know there is no efficent
: way. I just prvided posible solution that I have never used...

: Or to put it another way, I posted this so we could brain storm my idea
: and help someone along the way :) This code was never tested and should
: never be put on the web in a copy-paste fashion. Use your had and then
: use this code :)

: Anyway, you can always put "Testing your newtwork speed... Please wait"
: :-)

The microsoft client update software that runs on lans (can't think what
it's called right now) uses a similar test before deciding how best to
proceded.

If you had a specific client base where most people are normally connected
at high speed then your idea could be a good kludge to use before trying
to do something like send large documents, or etc. so like I said, I'm not
trying to put the idea down at all.

--

This space not for rent.
Jul 17 '05 #12
It should be possible, I think, to accomplish the same thing without
using javascript ( but with still using a redirecting "testing
connection speed" gateway page ).

If, at the top of your php script, you were to store the current
microtime into a session variable...Then output several kilobytes of
random characters inside an HTML comment...Finally output a <meta
HTTP-EQUIV='Refresh' Content='0; Url=target_page.php;'> tag. Then on
the target_page.php you could read the microtime again and compare it
to what you stored in the session.

-Ramius

p.s. - The reasoning for the random characters instead of just
whitespace is because it should hopefully slow the modem down more (
less compressible ). Also, beware that if your webserver is gzip'ing
your output, this will skew your results!
ev***************@gmail.com wrote:
Hi there,

Have you thought of javascript?


Jul 17 '05 #13
>
p.s. - The reasoning for the random characters instead of just
whitespace is because it should hopefully slow the modem down more (
less compressible ). Also, beware that if your webserver is gzip'ing
your output, this will skew your results!


Yeah, and make sure that the function returning the random string is
faster than the connection. ;)

Cheers
Mike
Jul 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Yang Li Ke | last post by:
Hi guys, Is it possible to know the internet speed of the visitors with php? Thanx -- Yang
5
by: chris | last post by:
hi all, is there a way that a script can detect the connection speed of a visitor, so that I can direct slower connection to a standard site and faster DSL/cable users to a flash copy of the...
12
by: Alban Hertroys | last post by:
Good day, I have a number of threads doing inserts in a table, after which I want to do a select. This means that it will occur that the row that I want to select is locked (by the DB). In these...
1
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the...
32
by: Victor | last post by:
I've been to a few websites where it displays the town, state (if USA), country I'm browsing from. Now, I know that detecting country is easy, but how do you determine the town? What ASP...
4
by: Frank Meng | last post by:
Hi. I am trying a csharp sample from http://www.codeproject.com/csharp/socketsincs.asp . (Sorry I didn't post all the source codes here, please get the codes from above link if you want to try)....
13
by: Shailesh Humbad | last post by:
Here is an advanced PHP question. Can anyone think of a way to detect the number of bytes written to output when a script is aborted? I am sending a large file to the client, and I want to record...
0
by: Arthur | last post by:
Hi, I am trying to write a windows service in VC++.NET 2003, the task of this server is to detect the kind of internet connection and if there is a connection send some file and do something. ...
1
by: Arielle | last post by:
I wasn't sure where to put this but anyway here's the idea and I'm wondering if it's possible. Help would be appreciated but if anyone has done this before regardless I can eventually figure it out...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.