PHP Asynchronous Client/Server Socket connection with SSL &

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
pgupta
New php-forum User
New php-forum User
Posts: 7
Joined: Fri Oct 15, 2010 7:37 am

PHP Asynchronous Client/Server Socket connection with SSL &

Post by 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

Post by 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);
}
?>

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests