src/Radius.php
private function sendRadiusRequest($packetData)
    {
        $packetLen  = strlen($packetData);

        $conn = @fsockopen('udp://' . $this->server, $this->authenticationPort, $errno, $errstr);
        if (!$conn) {
            $this->errorCode    = $errno;
            $this->errorMessage = $errstr;
            return false;
        }

        $sent = fwrite($conn, $packetData);
        if (!$sent || $packetLen != $sent) {
            $this->errorCode    = 55; // CURLE_SEND_ERROR
            $this->errorMessage = 'Failed to send UDP packet';
            return false;
        }

        if ($this->debug) {
            $this->debugInfo(
                sprintf(
                    '<b>Packet type %d (%s) sent to %s</b>',
                    $this->radiusPacket,
                    $this->getRadiusPacketInfo($this->radiusPacket),
                    $this->server
                )
            );
            foreach($this->attributesToSend as $attrs) {
                if (!is_array($attrs)) {
                    $attrs = array($attrs);
                }

                foreach($attrs as $attr) {
                    $attrInfo = $this->getAttributesInfo(ord(substr($attr, 0, 1)));
                    $this->debugInfo(
                        sprintf(
                            'Attribute %d (%s), length (%d), format %s, value <em>%s</em>',
                            ord(substr($attr, 0, 1)),
                            $attrInfo[0],
                            ord(substr($attr, 1, 1)) - 2,
                            $attrInfo[1],
                            $this->decodeAttribute(substr($attr, 2), ord(substr($attr, 0, 1)))
                        )
                    );
                }
            }
        }

        return $conn;
    }
private function sendRadiusRequest($packetData)
    {
        $packetLen  = strlen($packetData);

        $conn = @fsockopen('udp://' . $this->server, $this->authenticationPort, $errno, $errstr);
        if (!$conn) {
            $this->errorCode    = $errno;
            $this->errorMessage = $errstr;
            return false;
        }

        $sent = fwrite($conn, $packetData);
        if (!$sent || $packetLen != $sent) {
            $this->errorCode    = 55; // CURLE_SEND_ERROR
            $this->errorMessage = 'Failed to send UDP packet';
            return false;
        }

        if ($this->debug) {
            $this->debugInfo(
                sprintf(
                    '<b>Packet type %d (%s) sent to %s</b>',
                    $this->radiusPacket,
                    $this->getRadiusPacketInfo($this->radiusPacket),
                    $this->server
                )
            );
            foreach($this->attributesToSend as $attrs) {
                if (!is_array($attrs)) {
                    $attrs = array($attrs);
                }

                foreach($attrs as $attr) {
                    $attrInfo = $this->getAttributesInfo(ord(substr($attr, 0, 1)));
                    $this->debugInfo(
                        sprintf(
                            'Attribute %d (%s), length (%d), format %s, value <em>%s</em>',
                            ord(substr($attr, 0, 1)),
                            $attrInfo[0],
                            ord(substr($attr, 1, 1)) - 2,
                            $attrInfo[1],
                            $this->decodeAttribute(substr($attr, 2), ord(substr($attr, 0, 1)))
                        )
                    );
                }
            }
        }

        return $conn;
    }
private function sendRadiusRequest ( $ packetData ) { $ packetLen = strlen ( $ packetData ) ; $ conn = @ fsockopen ( 'udp://' . $ this -> server , $ this -> authenticationPort , $ errno , $ errstr ) ; if ( ! $ conn ) { $ this -> errorCode = $ errno ; $ this -> errorMessage = $ errstr ; return false ; } $ sent = fwrite ( $ conn , $ packetData ) ; if ( ! $ sent || $ packetLen != $ sent ) { $ this -> errorCode = 55 ; // CURLE_SEND_ERROR $ this -> errorMessage = 'Failed to send UDP packet' ; return false ; } if ( $ this -> debug ) { $ this -> debugInfo ( sprintf ( '<b>Packet type %d (%s) sent to %s</b>' , $ this -> radiusPacket , $ this -> getRadiusPacketInfo ( $ this -> radiusPacket ) , $ this -> server ) ) ; foreach ( $ this -> attributesToSend as $ attrs ) { if ( ! is_array ( $ attrs ) ) { $ attrs = array ( $ attrs ) ; } foreach ( $ attrs as $ attr ) { $ attrInfo = $ this -> getAttributesInfo ( ord ( substr ( $ attr , 0 , 1 ) ) ) ; $ this -> debugInfo ( sprintf ( 'Attribute %d (%s), length (%d), format %s, value <em>%s</em>' , ord ( substr ( $ attr , 0 , 1 ) ) , $ attrInfo [ 0 ] , ord ( substr ( $ attr , 1 , 1 ) ) - 2 , $ attrInfo [ 1 ] , $ this -> decodeAttribute ( substr ( $ attr , 2 ) , ord ( substr ( $ attr , 0 , 1 ) ) ) ) ) ; } } } return $ conn ; }
Send a RADIUS packet over the wire using UDP.

@param string $packetData  The raw, complete, RADIUS packet to send
@return boolean|resource   false if the packet failed to send, or a socket resource on success
Send a RADIUS packet over the wire using UDP .