hi there..
i have written a socket code which is not running and giving a warning that Socket_bind() unable to bind address.. can not assign requested address...
the code is attached..please have a look and do tell me its solution..
usman.

<?php

// set some variables
$host = "192.20.4.1";
$port= 3740;

// don't timeout1
set_time_limit(0);

//Create Socket
$socket= socket_create(AF_INET, SOCK_STREAM,SOL_TCP) or die ("could not create socket\n");

// bind socket to port
$result= socket_bind($socket,$host,$port) or die ("could not bind to socket\n");

// strat listenning to connections
$result=socket_listen($socket,3) or die ("could not set up socket listener\n");

//accept incomming connections
// spawn another socket to handle communication
$spawn= socket_accept($socket) or die ("could not accept incomming connection\n");

//read client input
$input= socket_read($spawn,1024) or die ("could not read input\n");

//Cleanup inout string
$input= trim($input);

//reverse client inout and send back
$output=strrev($input) . "\n";
socket_write($spawn,$output,strlen($output)) or die ("could not write output\n");

//close sockets
socket_close($spawn);
socket_close($socket);
?>

    This may sound like a stupid question but,

    Do you have Sockets Enabled in your PHP.ini file ?

      Write a Reply...