socket programming

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sri.sjc
Forum Newbie
Posts: 5
Joined: Wed Jan 30, 2008 7:34 am

socket programming

Post by sri.sjc »

hi folks,
i'm trying to develop an php application which would include php's socket programming.
But i get a fatal error saying that
Fatal error: Call to undefined function socket_create() in C:\wamp\www\SRI\Socke
t\socket.php on line 5

I've enabled the sockets in the php configuration file and restarted the server. But it doesn't work.
Can anybody help me? I'm using php 5.1.4 on windows platform.
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: socket programming

Post by hannnndy »

have you tried the correct arguments we do not know what happened on line 5 :))
sri.sjc
Forum Newbie
Posts: 5
Joined: Wed Jan 30, 2008 7:34 am

Re: socket programming

Post by sri.sjc »

i'm very sorry for not sending the coding. its like this
<?php
$host="192.168.1.99";
$port=1234;
set_time_limit(0);
$socket=socket_create(AF_INET,SOCK_STREAM,0) or die("Could not create socket");
$result=socket_bind($socket,$host,$port) or die("Could not bind to socket");
$result=socket_listen($socket,3) or die("Could not setup socket listener");
$spawn=socket_accept($socket) or die("Could not accept incoming connection");
$input=socket_read($spawn,1024) or die("Could not read input");
$input=trim($input);
$output=strrev($input)."\n";
socket_write($spawn,$output,strlen($output)) or die("Could not write output");
socket_close($spawn);
socket_close($socket);
?>
this give the fatal error on line 5.i've uncommented the ;extension=php_sockets.dll line in php.ini file by removing the preceding semicolon and i could see sockets enabled with my phpinfo(). what should i do? pls reply as early as possible. Is there any other way to send messages to computers on LAN?
Post Reply