Esempio n. 1
0
function SocketOpen()
{
    $ip = 'localhost';
    $port = 2333;
    $mainSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if (checkOK($mainSocket, 'Socket Create') == -1) {
        exit(-1);
    }
    $resBindResult = socket_bind($mainSocket, $ip, $port);
    if (checkOK($resBindResult, 'Sck bind') == -1) {
        exit(-1);
    }
    $resListenResult = socket_listen($mainSocket, 300);
    if (checkOK($resListenResult, 'Sck listen') == -1) {
        exit(-1);
    }
    echo "Listening " . $ip . ':' . $port . "....\n";
    return $mainSocket;
}
Esempio n. 2
0
}
$crash_guid = $_POST["crashguid"];
checkOK($crash_guid);
if (strlen($crash_guid) != 36) {
    done(450, "Crash GUID has wrong length.");
}
// Get file attachment
if (array_key_exists("crashrpt", $_FILES)) {
    // Check upload error code
    $error_code = $_FILES["crashrpt"]["error"];
    if ($error_code != 0) {
        done(450, "File upload failed with code {$error_code}.");
    }
    // Get temporary name uploaded file is stored currently
    $tmp_file_name = $_FILES["crashrpt"]["tmp_name"];
    checkOK($tmp_file_name);
    // Check that uploaded file data have correct MD5 hash
    $my_md5_hash = strtolower(md5_file($tmp_file_name));
    $their_md5_hash = strtolower($md5_hash);
    if ($my_md5_hash != $their_md5_hash) {
        done(451, "MD5 hash is invalid (yours is " . $their_md5_hash . ", but mine is " . $my_md5_hash . ")");
    }
    // Use crash GUID as file name
    $file_name = $file_root . $crash_guid . ".zip";
    // Move uploaded file to an appropriate directory
    if (!move_uploaded_file($tmp_file_name, $file_name)) {
        done(452, "Couldn't save data to local storage");
    }
} else {
    done(452, "File attachment missing");
}
Esempio n. 3
0
<?php

//$ip = '192.168.43.19';
$ip = 'localhost';
$port = 2332;
$resSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (checkOK($resSocket, 'Sock Create') == -1) {
    exit(-1);
}
$resClientConn = socket_connect($resSocket, $ip, $port);
if (checkOK($resClientConn, 'Sock Conn') == -1) {
    exit(-1);
}
echo "Starting Client";
//$msgFromServer = socket_read($resSocket, 2345);
echo $msgFromServer;
while (1) {
    $msgFromServer = socket_read($resSocket, 2345);
    if ($msgFromServer != "") {
        echo "Msg Recved !\n";
        echo "Msg is : " . $msgFromServer;
    }
}
socket_close($resSocket);
function checkOK($varr, $errType)
{
    if ($varr == FALSE) {
        echo $errType . " Failed\n";
        return -1;
    } else {
        echo $errType . " Success\n";
Esempio n. 4
0
<?php

error_reporting(E_ALL);
$port = 2332;
$ip = '0.0.0.0';
$resSocket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (checkOK($resSocket, 'Socket Create') == -1) {
    exit(-1);
}
$resBindResult = socket_bind($resSocket, $ip, $port);
if (checkOK($resBindResult, 'Sck bind') == -1) {
    exit(-1);
}
$resLisnResult = socket_listen($resSocket, 300);
if (checkOK($resLisnResult, 'Sck listen') == -1) {
    exit(-1);
}
echo "Listening " . $ip . ':' . $port . "....\n";
$cnt = 1;
while (1) {
    $commSocket = socket_accept($resSocket);
    if ($commSocket != FALSE) {
        $ttimasdf = "DMK is SB" . $cnt++;
        socket_write($commSocket, $ttimasdf, strlen($ttimasdf));
        socket_close($commSocket);
    }
}
socket_close($resSocket);
//$resConnResult = socket_connect($resSocket, $ip, $port);
//echo $resConnResult;
//echo socket_strerror(socket_last_error());