Hello,
i need someone who can code in PERL or C.
It’s just a simple socket programm, which is sending data through an SSL-socket. I coded the programm/script using PHP. But i need a timeout while reading the socket.
Problem: PHP has a bug. The function “stream_set_timeout” is not working in PHP when establishing a connection through “SSL”.
See first message: http://www.php.net/manual/de/function.stream-set-timeout.php#93298
Because of this, i need someone who can adopt the attached PHP code in PERL and/or C.
After sussesfully resolving this problem, more work can be done. I am looking for a long-time relationship with people who are able to have experience in (PERL and/or C and/or C++ and/or SystemAdmin and/or Shell-Scripting).
Please make your bid for the adaption of this code:
#!/usr/bin/php
<?
function connect()
{
global $rri_server;
$socket = fsockopen(“ssl://$rri_server”, 51131, $errno, $errstr);
if (!$socket) { echo “$errstr ($errno)<br />n”; exit; }
return $socket;
}
function sendData($msg)
{
global $socket;
$len = strlen($msg);
$lenBE = pack(“N”,$len);
fwrite($socket,$lenBE,4);
fwrite($socket,$msg,$len);
return $lenBE;
}
function getData()
{
global $socket;
// HERE YOU NEED TO IMPLMENT A TIMEOUT IN MICRO OR MILLISECONDS
// IN PHP IT WOULD BE LIKE
//
// stream_set_blocking($socket, TRUE );
// stream_set_timeout($socket, 0, 1);
//
// WHEN TIMEOUT HAPPENDS, FUNCTION getData() should EXIT and RETURN “TIMEOUT”
$lenBE = fgets($socket,5);
$len = unpack(“N”,$lenBE);
$len = $len[1];
$msg = fread($socket,$len);
return $msg;
}
$socket = connect();
sendData($msg_login);
$data = getData();
?>