Firefox extension and PHP socket

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all,
I'm having a problem with a simple Firefox extension that should
comunicate with a PHP script in a local network through a simple
When I execute the extension on the server where there is the PHP
script, it works fine.
When I try to execute it on different machine (in the same LAN) the
PHP script gives to me this error:

"Warning: socket_bind() [function.socket-bind]: unable to bind address
[99]: Cannot assign requested address in /var/www/socket_server.php on
line 21"

This is the extension javascript code:
function main()
  var host = "";
  var port = 9999;
  var delay = new Array();
  var lung_pkt = 288;
  var num_pkg = 100;
  var num_str = 12;
  var nPkg = 0;

  try {"http://"+host+"/

    var transportService = Components.classes["
    var transport = transportService.createTransport(null,

    var stream = transport.openInputStream(0,0,0);
    var instream = Components.classes["

    var dataListener = {
      onStartRequest: function(request, context){},
      onStopRequest: function(request, context, status) {
     var stampa="";
     var i=0;
     for(i=0; i<delay.length; i++) {
      onDataAvailable: function(request, context, inputStream, offset,
     var ora = new Date();
     var partenza = parseInt(,13));
     var arrivo = ora.getTime();
     var d = arrivo - partenza;

    var pump = Components.classes["
    pump.init(stream, -1, -1, 0, 0, false);
  } catch (ex){
  return null;

And this is the PHP code:
$host = "";
$port = 9999;
$lung_pkg = 288; //lunghezza del pacchetto, bytes
$periodo = 100;  //periodo di trasmissione, usec
$delta = 10000;  //pausa tra stream, usec
$num_pkg = 100;  //numero di pacchetti nello stream
$num_str= 12;    //numero di stream nel fleet

//numero di millisecondi trascorsi dalla UNIX Epoque
function timestamp() {
  list($usec, $sec) = explode(" ", microtime());
  $usec = substr($usec,2,3);
  $sec = $sec*1000;
  return $sec+$usec;

$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die(socket_strerror
echo(date("H:i:s")." Socket creata<br>");
socket_bind($socket, $host, $port) or die(socket_strerror
echo(date("H:i:s")." Socket connessa<br>");
socket_listen($socket) or die(socket_strerror(socket_last_error
echo(date("H:i:s")." Socket listener creato<br>");
$client = socket_accept($socket) or die(socket_strerror
echo(date("H:i:s")." Connessione accettata<br>");

//invio del fleet
for ($n=0; $n<$num_str; $n++) {
  //invio dello stream
  for ($k=0; $k<$num_pkg; $k++) {
    $output = timestamp();
    while(strlen($output)<$lung_pkg) $output.="A";
    socket_write($client, $output, $lung_pkg) or die(socket_strerror
  echo(date("H:i:s")." Stream $n inviato<br>");

echo(date("H:i:s")." Fine");

I hope that someone can help me.

Re: Firefox extension and PHP socket

Antonello wrote:
Quoted text here. Click to load it
<snip javascript code>
Quoted text here. Click to load it

Does the system running the script own the ip address  Or
does that belong to another computer (the working one)?

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline