You are here: Re: [PHP] Socket_connect producing errors that show no reason « PHP « IT news, forums, messages
Re: [PHP] Socket_connect producing errors that show no reason

Posted by Jochem Maas on 01/18/05 02:00

Adam Hubscher wrote:
> The code looks like this:
>
> if(($sock = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0){
> print("Couldn't Create Socket: " .
> socket_strerror(socket_last_error()). "\n");
> }
> socket_set_option($sock, SOL_SOCKET,SO_RCVTIMEO, array('sec' => 1,
> 'usec' => 0));
> $output = '';
> for($i = 0; $i < count($file); $i++){
> $servernum = $file[$i];
> $i++;
> $servername = $file[$i];
> $serverport = $file2[$i];
> $serverport = preg_replace('/\s/','',$serverport);
>
> // Test if server online - if not, output offline. If yes, output
> Online.
> if(!socket_connect($sock, $ip, $mapport)){
> print("Couldn't Create Socket: " .
> socket_strerror(socket_last_error()). "\n"); // Debug
> $output .= "Server Name: " . $servername. " ~~ Offline <br />";
> continue;
> }
> else{
> $output .= "Server Name: " . $servername. " ~~ Online <br />";
> }
> }
>
> My problem now is that as it runs through the loop - it has a connection
> error. Warning: socket_connect() [function.socket-connect]: unable to
> connect [106]: Transport endpoint is already connected in status.php on
> line 17


maybe you should close the socket before trying to open it again?
also where is $ip being set?

>
> Even looking at examples, I cannot figure out why this error is being
> produced. I cannot close the socket at the end of the loop, as it would
> make any further attempts for online status impossible.
>
> The socket_close($sock) is directly after the loop.
>
> Thanks for any help!
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация