PHP fsockopen doesnt return anything

Posted by Industrial on Stack Overflow See other posts from Stack Overflow or by Industrial
Published on 2010-05-20T17:56:10Z Indexed on 2010/05/20 18:00 UTC
Read the original article Hit count: 261

Filed under:
|
|

Hi! I am modifying a PHP db wrapper for the redis database.

Here's how my function looks:

public function connect() {

    $sock = @fsockopen('localhost', '6379',  $errno, $errstr, 2);

    if ($sock === FALSE) {
        return FALSE;
    }
    else {
        stream_set_timeout($sock, 2); 
        return $sock;
    }
}

What I want to do is to call this function from another part in my wrapper:

 if ($this->connect() !== FALSE) {
      // Do stuff
 }

How can I get my connect function to send a FALSE when the fsockopen isn't working?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about fsockopen