Socket_Connect returning unusual error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Warning: socket_connect() expects parameter 3 to be long, string given in testing.php on line 21
Couldn't Create Socket: Success


It actually spits that across for every socket I'm trying to connect.

I'm doing an online status for multiple servers, which I have tested to work when I simply do a socket_connect($sock,$url,$port); on the port numbers of the various servers. The servers all reside on the same IP address.

The script actually works manually, ie if i put the actual port in to the socket_connect function call. However, as soon as I put the variable in - it wont work.

The code looks like so:

foreach ($servers as $key => $value){

$currport = $servers[$key]['Port']; // was attempting this to see if it would work - it did not either. Normally tried $servers[$key]['Port'] directly.
if(!socket_connect($sock, $ip, $currport)){
print("Couldn't Create Socket: " . socket_strerror(socket_last_error()). "\n"); // Debugging purposes
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~ Offline <br />";
}
else{
$output .= "Server Name: " . $Servers[$key]['Name']. " ~~ Online <br />";
}
}


I cant quite find anything that is... actually wrong with the code. I dont understand the error all that much either, as it says "Success" in it. Needless to say - I'm thoroughly confused!

Anyone help me out?

Thanks!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux