Penso che le prese php e i flussi di php si sovrappongano.
Sono riuscito a creare un client di chat CLI PHP e un server, utilizzando socket o flussi.Php Socket vs Stream
Qui alcune linee di codice che illustrano:
usando socket:
...
$main_socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Cannot create socket.\n");
@socket_bind($main_socket, $host, $port) or die("Could not bind to socket $host : $port.\n");
@socket_listen($main_socket, 5) or die("Could not set up socket listener\n");
...
Uso flussi:
...
$main_socket = @stream_socket_server ("tcp://$host:$port", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN) or die("Cannot create socket.\n");
$clients = array($main_socket);
$clients_peername = array(array('port' => $port));
fputs(STDOUT, "Waiting for connections...\n");
...
Il punto è che un client e un server potrebbero essere resi usando sia le funzioni sockets , o funzioni di streaming.
So che Streams fa parte del core PHP e Sockets è un'estensione.
La mia domanda (s) è (sono):
- Qual è la differenza tra prese e corsi d'acqua quando si parla di programmazione socket?
- Esistono funzionalità correlate alla programmazione di socket, che è possibile avere mentre l'altra non può?
@JamWaffles Grazie per la modifica e mi dispiace per il mio inglese. –
Nessun problema. Il tuo inglese è quasi perfetto, quindi non c'è nulla di cui preoccuparsi :) – Bojangles