Socket context options

Socket context optionsSocket context option listing

Beschreibung

Socket context options are available for all wrappers that work over sockets, like tcp, http and ftp.

Optionen

bindto

Used to specify the IP address (either IPv4 or IPv6) and/or the port number that PHP will use to access the network. The syntax is ip:port for IPv4 addresses, and [ip]:port for IPv6 addresses. Setting the IP or the port to 0 will let the system choose the IP and/or port.

Hinweis:

As FTP creates two socket connections during normal operation, the port number cannot be specified using this option.

backlog

Used to limit the number of outstanding connections in the socket's listen queue.

Hinweis:

This is only applicable to stream_socket_server().

ipv6_v6only

Overrides the OS default regarding mapping IPv4 into IPv6.

Hinweis:

This is important in particular when trying to listen on IPv4 addresses separately while there exists a binding on [::].

This is only applicable to stream_socket_server().

so_reuseport

Allows multiple bindings to a same ip:port pair, even from separate processes.

Hinweis:

This is only applicable to stream_socket_server().

so_broadcast

Enables sending and receiving data to/from broadcast addresses.

Hinweis:

This is only applicable to stream_socket_server().

tcp_nodelay

Setting this option to true will set SOL_TCP,NO_DELAY=1 appropriately, thus disabling the TCP Nagle algorithm.

Changelog

Version Beschreibung
7.1.0 Added tcp_nodelay.
7.0.1 Added ipv6_v6only.

Beispiele

Beispiel #1 Basic bindto usage example

<?php
// connect to the internet using the '192.168.0.100' IP
$opts = array(
    
'socket' => array(
        
'bindto' => '192.168.0.100:0',
    ),
);


// connect to the internet using the '192.168.0.100' IP and port '7000'
$opts = array(
    
'socket' => array(
        
'bindto' => '192.168.0.100:7000',
    ),
);


// connect to the internet using the '2001:db8::1' IPv6 address
// and port '7000'
$opts = array(
    
'socket' => array(
        
'bindto' => '[2001:db8::1]:7000',
    ),
);


// connect to the internet using port '7000'
$opts = array(
    
'socket' => array(
        
'bindto' => '0:7000',
    ),
);


// create the context...
$context stream_context_create($opts);

// ...and use it to fetch the data
echo file_get_contents('http://www.example.com'false$context);

?>

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHPUnit in der Version 10 erschienen

Das beliebte Testframeworks PHPUnit ist in der Version 10 erschienen und steht zum Download bereit ...

TheMax

Autor : TheMax
Kategorie: Software & Web-Development

Laravel 10 veröffentlicht

Laravel Version 10 steht mit einer Mindestanforderung von PHP 8.1 zum Download bereit. ...

admin

Autor : admin
Kategorie: Software & Web-Development

DeepL Erweiterung Write als beta veröffentlicht

DeepL hat eine neuen Dienst Namens „write“ veröffentlicht, der die Rechtschreibung und Grammatik mit KI verbessern soll. ...

admin

Autor : admin
Kategorie: Dies und Das

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Aufsatz schreiben

Brauchen Sie Hilfe bei Ihrem Aufsatz? Ich kann Ihnen mit einer Empfehlung weiterhelfen und Sie über diesen Dienst informieren Ghostwriter Deutsch ...

Geschrieben von Faraon23 am 07.06.2023 18:56:39
Forum: Apps und PHP Script Gesuche
Welche Ghostwriter Agentur kontaktieren?

WirWRITE ist eine aussergewöhnliche Plattform, die Menschen in der Schweiz mit Erfahrene und seriöse Ghostwriter für alle Fachbereiche​ (http ...

Geschrieben von John534 am 07.06.2023 15:39:37
Forum: Off-Topic Diskussionen
Formular- Antwort

Das war es, ich musste der Datei einfach nur wieder :)den Originalnamen geben. Nun funktioniert es perfekt. Danke.

Geschrieben von Dirk66 am 21.05.2023 18:19:21
Forum: PHP Developer Forum
Formular- Antwort

Da scheint es die Datei form_einedatei.php nicht zu geben. Da du die Verarbeitung der Formulardaten im selben Script verwertest, kannst du auch sc ...

Geschrieben von scatello am 21.05.2023 14:10:16
Forum: PHP Developer Forum