dannybarh's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Active Members
Active Posts:
62 (0.05 per day)
Joined:
19-February 11
Profile Views:
2,299
Last Active:
User is offline Aug 03 2014 03:44 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   dannybarh has not set their status

Posts I've Made

  1. In Topic: GPS script on server not receiving gps data

    Posted 3 Aug 2014

    it is not working, it has disable on my my share host server. I will give this try and get back. Am using this script to receive data from a gps tracker. I you know any script that can work , i will be grateful, thanks.

    <?php
    error_reporting(E_ALL);
    
    /* Permitir al script esperar para conexiones. */
    set_time_limit(0);
    
    /* Activar el volcado de salida implícito, así veremos lo que estamo obteniendo
    * mientras llega. */
    ob_implicit_flush();
    
    $address = 'xxx.xxx.xxx.xx';
    $port = 443;
    
    if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
        echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "\n";
    }
    
    if (socket_bind($sock, $address, $port) === false) {
        echo "socket_bind() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    if (socket_listen($sock, 5) === false) {
        echo "socket_listen() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    //clients array
    $clients = array();
    
    do {
        $read = array();
        $read[] = $sock;
        
        $read = array_merge($read,$clients);
        
        // Set up a blocking call to socket_select
        if(socket_select($read,$write = NULL, $except = NULL, $tv_sec = 5) < 1)
        {
            //    SocketServer::debug("Problem blocking socket_select?");
            continue;
        }
        
        // Handle new Connections
        if (in_array($sock, $read)) {        
            
            if (($msgsock = socket_accept($sock)) === false) {
                echo "socket_accept() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
                break;
            }
            $clients[] = $msgsock;
            $key = array_keys($clients, $msgsock);
            /* Enviar instrucciones. */
            $msg = "\nBienvenido al Servidor De Prueba de PHP. \n" .
            "Usted es el cliente numero: {$key[0]}\n" .
            "Para salir, escriba 'quit'. Para cerrar el servidor escriba 'shutdown'.\n";
            socket_write($msgsock, $msg, strlen($msg));
            
        }
        
        // Handle Input
        foreach ($clients as $key => $client) { // for each client        
            if (in_array($client, $read)) {
                if (false === ($buf = socket_read($client, 2048, PHP_NORMAL_READ))) {
                    echo "socket_read() falló: razón: " . socket_strerror(socket_last_error($client)) . "\n";
                    break 2;
                }
                if (!$buf = trim($buf)) {
                    continue;
                }
                if ($buf == 'quit') {
                    unset($clients[$key]);
                    socket_close($client);
                    break;
                }
                if ($buf == 'shutdown') {
                    socket_close($client);
                    break 2;
                }
                $talkback = "Cliente {$key}: Usted dijo '$buf'.\n";
                socket_write($client, $talkback, strlen($talkback));
    
                // write received gprs data to the file
    			writeToFile('gprs.log', $buf);
                //echo "$buf\n";
            }
            
        }        
    } while (true);
    
    socket_close($sock);
    
    ?> 
    
  2. In Topic: GPS script on server not receiving gps data

    Posted 3 Aug 2014

    Is there another function for creating php sockets apart from this
    socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    
    ?

    Really need to know, thanks.
  3. In Topic: GPS script on server not receiving gps data

    Posted 2 Aug 2014

    lol, 33 views is enough for some one to say hi at lest.

    am getting this error
    Fatal error: Call to undefined function socket_create() in /home/www/domain.com/gps_listener.php on line 14
    

    I need to enable in php.ini
    extension=php_sockets.dll
    
    to solve the issue. My script is online, so how do i enable it online?

    Here is my revised code

    <?php
    error_reporting(E_ALL);
    
    /* Permitir al script esperar para conexiones. */
    set_time_limit(0);
    
    /* Activar el volcado de salida implícito, así veremos lo que estamo obteniendo
    * mientras llega. */
    ob_implicit_flush();
    
    $address = 'xxx.xxx.xxx.xx';
    $port = 80;
    
    if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
        echo "socket_create() falló: razón: " . socket_strerror(socket_last_error()) . "\n";
    }
    
    if (socket_bind($sock, $address, $port) === false) {
        echo "socket_bind() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    if (socket_listen($sock, 5) === false) {
        echo "socket_listen() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
    }
    
    //clients array
    $clients = array();
    
    do {
        $read = array();
        $read[] = $sock;
    
        $read = array_merge($read,$clients);
    
        // Set up a blocking call to socket_select
        if(socket_select($read,$write = NULL, $except = NULL, $tv_sec = 5) < 1)
        {
            //    SocketServer::debug("Problem blocking socket_select?");
            continue;
        }
    
        // Handle new Connections
        if (in_array($sock, $read)) {        
    
            if (($msgsock = socket_accept($sock)) === false) {
                echo "socket_accept() falló: razón: " . socket_strerror(socket_last_error($sock)) . "\n";
                break;
            }
            $clients[] = $msgsock;
            $key = array_keys($clients, $msgsock);
            /* Enviar instrucciones. */
            $msg = "\nBienvenido al Servidor De Prueba de PHP. \n" .
            "Usted es el cliente numero: {$key[0]}\n" .
            "Para salir, escriba 'quit'. Para cerrar el servidor escriba 'shutdown'.\n";
            socket_write($msgsock, $msg, strlen($msg));
    
        }
    
        // Handle Input
        foreach ($clients as $key => $client) { // for each client        
            if (in_array($client, $read)) {
                if (false === ($buf = socket_read($client, 2048, PHP_NORMAL_READ))) {
                    echo "socket_read() falló: razón: " . socket_strerror(socket_last_error($client)) . "\n";
                    break 2;
                }
                if (!$buf = trim($buf)) {
                    continue;
                }
                if ($buf == 'quit') {
                    unset($clients[$key]);
                    socket_close($client);
                    break;
                }
                if ($buf == 'shutdown') {
                    socket_close($client);
                    break 2;
                }
                $talkback = "Cliente {$key}: Usted dijo '$buf'.\n";
                socket_write($client, $talkback, strlen($talkback));
    
                // write received gprs data to the file
                writeToFile('gprs.txt', $buf);
                //echo "$buf\n";
            }
    
        }        
    } while (true);
    
    socket_close($sock);
    
    ?> 
    
  4. In Topic: Error installing fiverr clone

    Posted 12 Nov 2013

    yes i did, but no results
  5. In Topic: Search data in db where data is between two dates using sub query

    Posted 2 Nov 2013

    can you pls give an example of what you saying???

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

dannybarh has no profile comments yet. Why not say hello?