Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //$this->resource è la mia socket
- //Ho dovuto impostare queste opzioni array( "sec" => 1, "usec" => 0 ), altrimenti tutto restava in attesa senza ritornare niente.
- socket_set_option( $this->resource, SOL_SOCKET, SO_RCVTIMEO, array( "sec" => 1, "usec" => 0 ) );
- //Inizializzo le variabili
- $buf = "";
- $output = "";
- //Fino a quando socket_recv è true ciclo 1024 byte alla volta
- while ( false !== socket_recv( $this->resource, $buf, 1024, MSG_WAITALL ) ) {
- if ( $buf != null ) {
- //Appendo i dati stringa letti alla variabile $output
- $output .= $buf;
- }
- }
- //Ritorno il tutto
- return $output;
Advertisement
Add Comment
Please, Sign In to add comment