note 94350 added to function.socket-connect
| From: | peter at videoripper dot org | Date: | Thu, 29 Oct 2009 19:29:19 +0000 |
| Subject: | note 94350 added to function.socket-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162264@lists.php.net to get a copy of this message | ||
This will give you a simple port-checker.
Note that on production-machines, you might want to alter the error reporting-level,
since unsuccessful connects will give you a "No connection could be made because
the target machine actively refused it"-error in the log.
Under Windows, make sure you enable the php_sockets.dll extension in your php.ini.
<?php
$address=$_SERVER['REMOTE_ADDR'];
if (isset($_REQUEST['port']) and
(!strlen($_REQUEST['port'])==0))
$port=$_REQUEST['port'];
else
unset($port);
if (isset($port) and
($socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and
(socket_connect($socket, $address, $port)))
{
$text="Connection successful on IP $address, port $port";
socket_close($socket);
}
else
$text="Unable to
connect<pre>".socket_strerror(socket_last_error())."</pre>";
echo "<html><head></head><body>".
$text.
"</body></html>";
?>
Greetz,
Peter.
----
Server IP: 69.147.83.197
Probable Submitter: 83.82.6.59
----
Manual Page -- http://www.php.net/manual/en/function.socket-connect.php
Edit -- https://master.php.net/note/edit/94350
Del: integrated -- https://master.php.net/note/delete/94350/integrated
Del: useless -- https://master.php.net/note/delete/94350/useless
Del: bad code -- https://master.php.net/note/delete/94350/bad+code
Del: spam -- https://master.php.net/note/delete/94350/spam
Del: non-english -- https://master.php.net/note/delete/94350/non-english
Del: in docs -- https://master.php.net/note/delete/94350/in+docs
Del: other reasons-- https://master.php.net/note/delete/94350
Reject -- https://master.php.net/note/reject/94350
Search -- https://master.php.net/manage/user-notes.php