socket_connect example

return true;
    }

    function _connect($host$port) {
        $this->SendMSG("Creating socket");
        if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
            $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
            return FALSE;
        }
        if(!$this->_settimeout($sock)) return FALSE;
        $this->SendMSG("Connecting to \"".$host.":".$port."\"");
        if (!($res = @socket_connect($sock$host$port))) {
            $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
            @socket_close($sock);
            return FALSE;
        }
        $this->_connected=true;
        return $sock;
    }

    function _readmsg($fnction="_readmsg"){
        if(!$this->_connected) {
            $this->PushError($fnction,'Connect first');
            
Home | Imprint | This part of the site doesn't use cookies.