Fatal error: Call to undefined function socket_create()

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
hudsucker
-


Joined: 24 May 2006
Posts: 7

PostPosted: Wed May 24, 2006 6:59 pm    Post subject: Fatal error: Call to undefined function socket_create() Reply with quote

Hi every one;


Fatal error: Call to undefined function socket_create() in C:\ProgramFiles\Abyss Web Server\htdocs\Newping\index.php on line 28


I get the error above trying to run ping script on abyss.
I did remove the : in front of extension=php_sockets.dll restarted the server
no changes. Below you find the script I try to run - searched on google could not find any thing else.Please help!! :(

Thanks Lawrence
<?
function icmpChecksum($data)
{
if (strlen($data)%2)
$data .= "\x00";

$bit = unpack('n*', $data);
$sum = array_sum($bit);

while ($sum >> 16)
$sum = ($sum >> 16) + ($sum & 0xffff);

return pack('n*', ~$sum);
}
// Making the package
$type= "\x08";
$code= "\x00";
$checksum= "\x00\x00";
$identifier = "\x00\x00";
$seqNumber = "\x00\x00";
$data= "Scarface";
$package = $type.$code.$checksum.$identifier.$seqNumber.$data;
$checksum = icmpChecksum($package); // Calculate the checksum
$package = $type.$code.$checksum.$identifier.$seqNumber.$data;
// And off to the sockets
$socket = socket_create(AF_INET, SOCK_RAW, 1); this is the line
socket_connect($socket, "www.google.com", null);
// If you're using below PHP 5, see the manual for the microtime_float
// function. Instead of just using the m
// icrotime() function.
$startTime = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255)) {
echo round(microtime(true) - $startTime, 4) .' seconds';
}
socket_close($socket);
?>
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed May 24, 2006 7:51 pm    Post subject: Reply with quote

Can you paste the output of running phpinfo()? Did you compile PHP yourself?
Also, according to the PHP manual you don't need an extension for socket_create().
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
hudsucker
-


Joined: 24 May 2006
Posts: 7

PostPosted: Wed May 24, 2006 10:07 pm    Post subject: Reply with quote

MonkeyNation wrote:
Can you paste the output of running phpinfo()? Here you go:
PHP Version 5.1.2

System Windows NT CAPGEMIN-D6XYT1 5.1 build 2600
Build Date Jan 11 2006 16:35:21
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API CGI/FastCGI
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS\php.ini
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, zlib.*

Did you compile PHP yourself?I am not sure what you mean by that?
I found the scritp on wep.
Also, according to the PHP manual you don't need an extension for socket_create().
Back to top View user's profile Send private message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Wed May 24, 2006 10:12 pm    Post subject: Reply with quote

You probably need to enable the socket-extension. Just look in your php.ini-file and remove the ; from the line where the extension is located. It's probably called something like php_sockets.dll.
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu May 25, 2006 7:51 am    Post subject: Reply with quote

cmxflash wrote:
You probably need to enable the socket-extension. Just look in your php.ini-file and remove the ; from the line where the extension is located. It's probably called something like php_sockets.dll.


If you read his first post he already did that and it didnt work.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu May 25, 2006 9:42 am    Post subject: Reply with quote

Oh right, I thought the windows binaries had it enabled by default.
In that case, yeah, you'll have to uncomment the extension in php.ini.

If you already have, and it didn't seem to work, run phpinfo() once again, and look for where it reports php.ini to be located. Is that the one you edited?
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu May 25, 2006 10:47 am    Post subject: Re: Fatal error: Call to undefined function socket_create() Reply with quote

hudsucker wrote:
Hi every one;


Fatal error: Call to undefined function socket_create() in C:\ProgramFiles\Abyss Web Server\htdocs\Newping\index.php on line 28


I get the error above trying to run ping script on abyss.
I did remove the : in front of extension=php_sockets.dll restarted the server


Are you sure you have updated the right php.ini file? According to your phpinfo() output, you should change C:\WINDOWS\php.ini .

If you are using FastCGI with PHP, you must restart the web server to ensure that the updated php.ini is taken into account.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
hudsucker
-


Joined: 24 May 2006
Posts: 7

PostPosted: Thu May 25, 2006 10:49 am    Post subject: Reply with quote

MonkeyNation wrote:
Oh right, I thought the windows binaries had it enabled by default.
In that case, yeah, you'll have to uncomment the extension in php.ini.<-I am new to php what you mean by uncomment the extension

If you already have, and it didn't seem to work, run phpinfo() once again, and look for where it reports php.ini to be located. Is that the one you edited?<-in fact it is the only one I found on pc
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Thu May 25, 2006 11:29 am    Post subject: Reply with quote

If C:\WINDOWS\php.ini was the one you edited, then you edited the correct one.

Like aprelium said, try restarting abyss too.
Also, you could see what PHP does from the command line.
I.E. Start > Run > cmd.exe > cd C:\PHP & php -m . Does sockets appear on that list? (Also, if you don't have PHP in C:\PHP, change that bit.)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
hudsucker
-


Joined: 24 May 2006
Posts: 7

PostPosted: Fri Jun 02, 2006 6:43 pm    Post subject: Reply with quote

You were right running from CMD I got - PHP Warning: PHP Star
The specified module c
in Unknown on line 0 can I load that dll some how?
By the way thank you for such quick responce!! :D
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Jun 03, 2006 6:55 pm    Post subject: Reply with quote

hudsucker,

We recommend installing the preconfigured PHP 5 package from http://www.aprelium.com/abyssws/php5win.html . It has all the extensions and scokets are enabled by default.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group