What is Delphi equivalent to “fsockopen” function in php?
in PHP Manual:
resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
Initiates a socket connection to the resource specified by hostname.
My code is fully:
function accountcreate($username, $password, $connection, $bandwidth, $disabledate, $disabletime)
{
$adminpassword='';
$adminport=82;
$proxyaddress='127.1.1.1';
$fp = fsockopen($proxyaddress, $adminport, &$errno, &$errstr, 1000);
if(!$fp)
{
echo "$errstr ($errno)<br>\n";
}
else
{
$url_ = "/account";
$url = "add=1"."&";
.
.
$url = $url."userid=-1";
$len = "Content-Length: ".strlen($url);
$auth = "Authorization: Basic ".base64_encode("admin:".$adminpassword);
$msg = "POST ".$url_." HTTP/1.0\r\nHost: ".$proxyaddress."\r\n".$auth."\r\n".$len."\r\n"."\r\n".$url;
fputs($fp,$msg);
echo $msg;
fclose($fp);
}
that code make a new account in ccproxy.
Perhaps have a look at the Indy Components that ship with Delphi (assuming at least Delphi7). You would need :
TIdTCPConnection Documentation
which contains an
IOHandlerproperty (TIdIOHandler) where you specify the parameters used infsockopen:TIdTCPConnection.IOHandler Property
TIdIOHandler Documentation
As others have noted, however, you probably would be well served by looking at the bigger picture in your PHP code and perhaps implementing its functionality with a higher level tool like
TIdHTTP:TIdHTTP Documentation