Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP Asynchronous Client/Server Socket connection with SSL &

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP Asynchronous Client/Server Socket connection with SSL &

Postby pgupta » Mon May 27, 2013 3:58 am

Query :
Last edited by pgupta on Mon May 27, 2013 4:10 am, edited 1 time in total.
pgupta
New php-forum User
New php-forum User
 
Posts: 7
Joined: Fri Oct 15, 2010 7:37 am

Re: PHP Asynchronous Client/Server Socket connection with SS

Postby pgupta » Mon May 27, 2013 4:03 am

Hi everyone,

Please guide me in the Client and server websocket connections with SSL encyption + asynchronous.

Let me know is there any way to do this in PHP?

Thanks in advance.

:help: :help:

Hi for supportive, i did the following code spec but some how its not working as per the requirement.

Socket client connection :

Code: Select all
<?php

$ip="111.111.0.111";               //Set the TCP IP Address to connect too
$port="7109";                  //Set the TCP PORT to connect too

#Connect to Server
$socket = stream_socket_client("tcp://{$ip}:{$port}", $errno, $errstr, 30,STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);

if($socket) {
   #Start SSL
   stream_set_blocking ($socket, true);
   stream_socket_enable_crypto ($socket, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);   
   stream_set_blocking ($socket, false);
   
   $buf = null;
   #Receive response from server. Loop until the response is finished
   while (!feof($socket)) {
      $buf .= fread($socket, 4);
   }

   #echo our command response
    echo $buf;
       
        #close connection
   fclose($socket);
}
?>
pgupta
New php-forum User
New php-forum User
 
Posts: 7
Joined: Fri Oct 15, 2010 7:37 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.