Jump to content
  • 0

сокеты?


odalex
 Share

Question

		function send($url) {

// Get xml document
$strXML = $this->toString();

// Get url parts
if (!preg_match("/http/", $url)) $url = "http://".$url;
$urlParts = parse_url($url);
$host = isset($urlParts['host'])?$urlParts['host']:'localhost';
$port = isset($urlParts['port'])?$urlParts['port']:80;
$path = isset($urlParts['path'])?$urlParts['path']:"/";

// Open a connection with the required host
$fp = fsockopen($host, $port, $errno, $errstr);
if (!$fp)
XML_DOMException::raise(XML_UNABLE_TO_CONNECT,
'Unable to connect to '.$host.' at port '.$port.': ('.$errno.
') '.$errstr);

// Send the xml document
fputs($fp, "POST ".$path." HTTP/1.0rn".
"Host: ".$host."rn".
"Content-length: ".strlen($strXML)."rn".
"Content-type: ".$this->contentType."rn".
"Connection: closernrn".
$strXML."rn");

return $fp;

} // send

вот есть функция которая что то шлет php скрипту, как php скриптом принять это дело?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Абсолютно обычным способом.

Вот только кроме сборки запроса из непонятных переменных было бы желательно увидеть итоговый текст запроса, особенно Content-Type.

Вычитать же POST можно (если $_POST не устраивает) из стандартного потока php://stdin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy