hi there..
i have written a php's socket code.. but it is not working. giving error in function socket_create(); could any one debug it and tell me whats to do..i am attatching the php file..please help me..
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, 0) 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);
?>