Saturday, 3 December 2011

create socket in php


A socket connection can be created in php using the code snippet below. 
This code snippet also shows how to write into a socket and read from a socket using php.
.......
.......
$SERVER_IP = 'x.x.x.x';
$SERVER_PORT = 'yy';
$Server = socket_create(AF_INET, $SOCK_STREAM, $SOL_TCP);
if($ServerConnected = @socket_connect($Server, $SERVER_IP, $SERVER_PORT))
{
@socket_write($Server , 'hello');
@socket_read($Server , 256);
........
}
.......
.......


No comments:

Post a Comment

Visual comparison of the two methods, creating a simple table.

Option 1, using PHP: // PHP $html = '<table>' ;     foreach ( $data as $row ) {     $html .= '<tr>...