Jump to content

Pull from NTP through proxy


Recommended Posts


I tried a function by @kor here: 

But it does not work through a proxy. So I tried a bit. With some forum help months ago I had a www-solution through a proxy for some other stuff. But trying it with ntp didn't work.

#include <WinHttp.au3>
Global Const $sProxy = "http://prx01.xxx.de:8080"
Global Const $sUserName = "UserName", $sPassword = "PassWord"
$vOpen = _WinHttpOpen(Default, $WINHTTP_ACCESS_TYPE_NAMED_PROXY, $sProxy)
$vConnect = _WinHttpConnect($vOpen, "pool.ntp.org", 123) ; Port 123
$vRequest = _WinHttpSimpleSendRequest_ProxyAuth($vConnect)
Global $sSource = _WinHttpSimpleReadData($vRequest)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sSource = ' & $sSource & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Func _WinHttpSimpleSendRequest_ProxyAuth($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sDta = Default, $sHeader = Default)
    Local $hRequest = _WinHttpSimpleSendRequest($hConnect, $sType, $sPath, $sReferrer, $sDta, $sHeader)
    If $hRequest Then
        Local $iStatusCode = _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE)
        If $iStatusCode = $HTTP_STATUS_PROXY_AUTH_REQ Then
            Local $iSupportedSchemes, $iFirstScheme, $iAuthTarget ; Query Authorization scheme
            If _WinHttpQueryAuthSchemes($hRequest, $iSupportedSchemes, $iFirstScheme, $iAuthTarget) Then
                _WinHttpSetCredentials($hRequest, $iAuthTarget, $iFirstScheme, $sUserName, $sPassword) ; Set passed credentials
                _WinHttpSendRequest($hRequest)  ; Set passed credentials
                _WinHttpReceiveResponse($hRequest) ; And wait for the response again
    Return $hRequest

(This snippet only tries to get raw data.) 

$sSource is "". With no port (instead of 123) I only get the informations I see when I type url into a browser - so it's not the information I seek. (There is not time included in http source code.)

Some hints? Regards, Conrad

SciTE4AutoIt =   AutoIt =   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...