socket_create example


        if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
            $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
            @socket_close($sock);
            return FALSE;
        }
        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;
        
Home | Imprint | This part of the site doesn't use cookies.