array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'context.socket.php', 1 => 'Socket-Kontextoptionen', ), 'up' => array ( 0 => 'context.php', 1 => 'Kontextoptionen und -parameter', ), 'prev' => array ( 0 => 'context.php', 1 => 'Kontextoptionen und -parameter', ), 'next' => array ( 0 => 'context.http.php', 1 => 'HTTP-Kontextoptionen', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'de', 'path' => 'language/context/socket.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
Socket-Kontextoptionen — Liste der Socket-Kontextoptionen
Socket-Kontextoptionen sind für alle Wrapper verfügbar, die über Sockets
arbeiten, wie tcp
, http
und
ftp
.
Version | Beschreibung |
---|---|
7.1.0 |
tcp_nodelay wurde hinzugefügt.
|
7.0.1 |
ipv6_v6only wurde hinzugefügt.
|
Beispiel #1 Grundlegendes Beispiel für die Verwendung von bindto
<?php
// Verbindung zum Internet über die IP-Adresse '192.168.0.100' aufbauen
$opts = array(
'socket' => array(
'bindto' => '192.168.0.100:0',
),
);
// Verbindung zum Internet über die IP-Adresse '192.168.0.100'
// und den Port '7000' aufbauen
$opts = array(
'socket' => array(
'bindto' => '192.168.0.100:7000',
),
);
// Verbindung zum Internet über die IPv6-Adresse '2001:db8::1'
// und den Port '7000' aufbauen
$opts = array(
'socket' => array(
'bindto' => '[2001:db8::1]:7000',
),
);
// Verbindung zum Internet über Port '7000' aufbauen
$opts = array(
'socket' => array(
'bindto' => '0:7000',
),
);
// den Kontext erstellen...
$context = stream_context_create($opts);
// ...und ihn zum Abrufen der Daten verwenden
echo file_get_contents('http://www.example.com', false, $context);
?>