Hi Gelu, At 21:52 2-6-2002, Gelu Gogancea shared with all of us:
>Indeed, mysql_simple_command (with COM_PING command like argument ) is used >by C API mysql_ping, to check connection.MYSQL struct it's used like >handler. >For a connection you must use in order: >mysql_init(), -initialise MYSQL struct >mysql_options(), - option for connection(set >TIMEOUT_CONNECTION,SSL....) >mysql_real_connect(). -the user authentification and connection >(User,Password,DataBase,Server Port....) Ok - that helps a bit. >So... you don't need mysql_ping ... unless if want to check periodical if >the server is "alive". Yes and no. I do want that, but afterwards I want to connect. I'll explain: If a networked host is down (the entire machine that is), and you use mysql_connect - in PHP, not in C - it will timeout indefenitely (or until max_execution_time php setting). Now - in a production environment that's unacceptable and we replicate our servers, so - I wrote a little php class, that handles this - using the socket extension in php. The relevant code boils down to this: <?php if($sp = fsockopen($this->dbHost, $this->dbPort, $errno, $errstr, $this->pingTimeout)) { fclose($sp); mysql_connect($this->dbHost, $this->dbPort, $this->dbUser, $this->dbPassword); } else { //setup ping to other server and connect if succesfull } ?> Now - here's a timeout, that disconnects, no matter what tcp/ip problem there is. However - this creates and invalid connection and the host_connect_errors is raised. So - there is some sort of protocol - that makes a valid connection, ie: 1) open socket 2) read greeting and get auth string 3) return right response 4) do stuff 5) close Now - 3-5 are my problem - not in MySQL C API, but in a simple tcp/ip socket communication layer - I want to mimmick that behavior in php. Best regards, Melvyn Sopacua WebMaster IDG.nl _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ If it applies, where it applies - this email is a personal contribution and does not reflect the views of my employer IDG.nl. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php