Re: Using sockets?

From: Date: Thu, 26 Oct 2000 15:52:39 +0000
Subject: Re: Using sockets?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22158@lists.php.net to get a copy of this message
Brad Jackson generously posted some sample code for me a few days ago. I modified it, to my style a bit. Alan <?php function PostToHost($host, $port, $path, $data_to_send, $authorization) { $fp = fsockopen($host, $port); if (!$fp) { $errorMsg = "<B>From PostToHost()</B><BR>"; $errorMsg .= "<B>Error:</B> Error opening network socket.<BR>"; return $errorMsg; } set_socket_blocking($fp, TRUE); $length = strlen($data_to_send); fwrite($fp, "POST $path HTTP/1.0\r\n"); if ($authorization != "") { fwrite($fp, "Authorization: Basic " . base64_encode($authorization) . "\r\n"); } fwrite($fp, "Host: $host\r\n"); fwrite($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fwrite($fp, "Content-length: $length\r\n"); fwrite($fp, "Connection: close\r\n\r\n"); fwrite($fp, $data_to_send); $results = ""; while (!feof($fp)) { $results .= fread($fp, 10000000); } fclose($fp); return $results; } ?>

Attachment: [application/x-pkcs7-signature] smime.p7s
« previous php.general (#22158) next »