<?php $service_port = 80; $address = gethostbyname('xx.xx.xx.xx'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { } else { } $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { } $in = "HEAD / HTTP/1.1\r\n"; $in .= "Host: www.example.com\r\n"; $in .= "Connection: Close\r\n\r\n"; $out = ''; while ($out = socket_read($socket, 2048)) { } socket_close($socket); ?>
Odpowiedz dostaję taką:
Kod
HTTP/1.1 200 OK
Date: Wed, 22 Aug 2012 09:14:31 GMT
Server: Apache/2.2.16 (Debian)
Last-Modified: Wed, 22 Aug 2012 08:07:51 GMT
ETag: "6a317c-b1-4c7d63d3a6c3c"
Accept-Ranges: bytes
Content-Length: 177
Vary: Accept-Encoding
Connection: close
Content-Type: text/html
Date: Wed, 22 Aug 2012 09:14:31 GMT
Server: Apache/2.2.16 (Debian)
Last-Modified: Wed, 22 Aug 2012 08:07:51 GMT
ETag: "6a317c-b1-4c7d63d3a6c3c"
Accept-Ranges: bytes
Content-Length: 177
Vary: Accept-Encoding
Connection: close
Content-Type: text/html
A chciałbym dostać taką odpowiedz:
Kod
HTTP/1.1 200 OK
Wed, 22 Aug 2012 09:14:31 GMT
Apache/2.2.16 (Debian)
Wed, 22 Aug 2012 08:07:51 GMT
Content-Type: text/html
Wed, 22 Aug 2012 09:14:31 GMT
Apache/2.2.16 (Debian)
Wed, 22 Aug 2012 08:07:51 GMT
Content-Type: text/html
Bez tych tekstów jak np.: Date, Server itp..
Jak take coś zrobić ?.
Poradziłem sobie już, str_replace używałem w pętli, ale zrobiłem funkcję z str_replace i wstawiłem ją i działa
