English
Units

Daytime Protocol Unit - Internetzeit over Zeitserver

 

Andre
Rohland
Hello dear Community,

i'm already one quite old Profan - Dino ( since Version 5.5 ).
The development of Profan have I To to actually Version always attentive and keen chasing, though always only Background, because I time with Thomas Hölzer gefetzt and me for not really Komplimente the then Profanergruppe eingefangen have... .

Currently bastle I one Program, which requires, that The System-Time possible very updated, or. abgerufen becomes.

For this have I already several Lösungsansätze seen, though came tappt im dunkeln me to that part as:
1. To tricky and
2. To big
to, particularly if one only The actually Time beötigt.

God Thanks there still Server, The The actually Time and the date over the so-called Daytime-Protocol as String give back. The disadvantage is only, that this log not eindeutig definiert is, so that different Server too different Strings give back... .

Perhaps can someone of you these Unit use, i'd me above forward.
View source there naturally on inquire... .

greetings
André Rohland

7 kB
Hochgeladen:02/02/09
Downloadcounter263
Download
 
02/02/09  
 



Regards! NTP  [...]  is objectively quite wirrig.


View source there naturally on inquire... .


inquire!
 
02/03/09  
 




Andre
Rohland
have whom View source another little comments.
Inettime
 $L
Def WSAStart(2) !wsock32.dll,WSAStartup
Def socket(3) !wsock32.dll,socket
Def WSAAsyncSelect(4) !wsock32.dll,WSAAsyncSelect
Def htons(1) !wsock32.dll,htons
Def connect(3) !wsock32.dll,connect
Def gethostbyname(1) !wsock32.dll,gethostbyname
Def recv(4) !wsock32.dll,recv
Def ioctlsocket(3) !wsock32.dll,ioctlsocket
Def closesocket(1) !wsock32.dll,closesocket
Def WSAClean(0) !wsock32.DLL,WSACleanup
Def WSAGetLastError(0) !wsock32.dll,WSAGetLastError
Def RtlMoveMemory(3) !kernel32,RtlMoveMemory
Def InternetGetConnectedState(2) !WININET.DLL,InternetGetConnectedState
Def SetSystemTime(1) !KERNEL32,SetSystemTime
Def SetLocalTime(1) !KERNEL32,SetLocalTime
USERMESSAGES 4100    Message, The appears, if one Netzwerkereignis stattfindet (WSAAsyncSelect)

proc ?_getTime

    parameters netadr$,netport&,count&,pointer&,erlaubt&
    Winsock - variables
    declare wsaerror&,Inetadresse#,sockaddr_in#,zwbuf#,avdat&
    declare dummy&,hostent#,xnetport&,xnetorderadr&,wsadata#,mysocket&
    dim Inetadresse#,255
    dim wsadata#,526
    dim sockaddr_in#,16
    dim hostent#,$5000
    control and Control
    declare  end%,Result$,tstring$
    System-Time etc
    declare wYear%,wMonth%,wDay%,wHour%,wMinute%,wSecond%
    Result$ =
    Bich I (already) drin ???

    ifnot InternetGetConnectedState(0,0)

        Result$ = error 1
        return Result$

    endif

    Winsock.dll initialisieren
    clear wsadata#

    if WSAStart($101,wsadata#)

        Result$ = error 2
        return Result$

    endif

    Streamsocket produce
    P1: (AF_INET = 2) internet log Version 4 (IPv4) Adressfamilie/// P2: (SOCK_STREAM = 1)
    it should one Streamsocket created go/// P3: 0 - Provider certainly the log
    mysocket&=socket(2,1,0)

    if mysocket& = -1

        Result$ = error 3
        WSAClean()
        return Result$

    endif

    Nonblocking mode / User Message übergeben

    if WSAAsyncSelect(mysocket&,%hwnd,4100,$1) <> 0

        Result$ = error 4
        closesocket(mysocket&)
        WSAClean()
        return Result$

    endif

    clear Inetadresse#
    string Inetadresse#,0=netadr$
    dummy&=gethostbyname(Inetadresse#)     supply Pointer on Hostent - structure

    if dummy& = 0                          Internetadresse could not found/ aufgelöst go

        Result$ = error 5
        closesocket(mysocket&)
        WSAClean()
        return Result$

    endif

    clear hostent#
    copy the Info from the hostent - structure ( dummy& ) in The Own Memory-Variable hostent#
    RtlMoveMemory(hostent#,dummy&,16)
    dummy&=long(hostent#,12)
    RtlMoveMemory(hostent#,dummy&,4)
    dummy&=long(hostent#,0)
    RtlMoveMemory(hostent#,dummy&,255)
    xnetorderadr&=long(hostent#,0)
    xnetport&=htons(netport&)
    structure for winsock connect (log, Port, address ) fill
    word sockaddr_in#,0=2 AF_inet
    word sockaddr_in#,2=xnetport&
    long sockaddr_in#,4=xnetorderadr&
    Streamsocket contact...
    wsaerror& = connect(mysocket&,sockaddr_in#,16)

    if wsaerror& = -1

        wsaerror& = WSAGetLastError()

        ifnot (wsaerror& = 10035) | (wsaerror& = 0)  0 = no Error, 10035 = WSAWOULDBLOCK, these

            Result$ = error 6                       Message results because of the NonBlocking - mode,
            closesocket(mysocket&)                      is but for us unbeachtlich
            WSAClean()
            return Result$

        endif

    endif

    The follow up Loop could abgeändert go, because in example SLEEP count& (= Parameter P3)
    uses and The amount the Durchläufe herabgesetzt becomes
    likewise could too The USERMESSAGE 4100 quizzed go, for whom of me intended object
    genügte these Variante ( i.d.R. lying one Result to about 50 Durchläufen to ).

    if Result$ =

        avdat&=0

        Whileloop count&

            ioctlsocket(mysocket&,$4004667F,addr(avdat&))  $4004667F = FIONREAD - checks whether data receive

            if avdat& > 0                                  get and gives The amount in avdat& back

                dim zwbuf#,avdat&
                clear zwbuf#
                recv(mysocket&,zwbuf#,avdat&,0)               reads The amount the conceived data (avdat&)
                break                                         in zwbuf# one

            endif

        endwhile

        if avdat& > 0

            Result$ = string $(zwbuf#,0)
            Result$=translate $(Result$,chr $(13)+chr $(10),)   Carriage return / Line Feed Remove

            ifnot pointer&=0                              Parameter 4 the Unit, pointer& is The address

                wYear% = val(right$(Result$,4))            of/ one übergebenen SystemTime - structure
                RtlMoveMemory(pointer&,addr(wYear%),2)       structure becomes filled....
                case instr(JAN,Upper $(Result$)) : wMonth% = 1
                case instr(FEB,Upper $(Result$)) : wMonth% = 2
                case instr(MAR,Upper $(Result$)) : wMonth% = 3
                case instr(APR,Upper $(Result$)) : wMonth% = 4
                case instr(MAY,Upper $(Result$)) : wMonth% = 5
                case instr(JUN,Upper $(Result$)) : wMonth% = 6
                case instr(JUL,Upper $(Result$)) : wMonth% = 7
                case instr(AUG,Upper $(Result$)) : wMonth% = 8
                case instr(SEP,Upper $(Result$)) : wMonth% = 9
                case instr(OCT,Upper $(Result$)) : wMonth% = 10
                case instr(NOV,Upper $(Result$)) : wMonth% = 11
                case instr(DEC,Upper $(Result$)) : wMonth% = 12
                RtlMoveMemory(pointer&+2,addr(wmonth%),2)
                wDay% = val(substr$(Result$,3,chr $(32)))
                RtlMoveMemory(pointer&+6,addr(wDay%),2)
                tstring$ = substr$(Result$,4,chr $(32))
                wHour% = val(substr$(tstring$,1,:))
                RtlMoveMemory(pointer&+8,addr(wHour%),2)
                wMinute% = val(substr$(tstring$,2,:))
                RtlMoveMemory(pointer&+10,addr(wMinute%),2)
                wSecond% = val(substr$(tstring$,3,:))
                RtlMoveMemory(pointer&+12,addr(wSecond%),2)

            else

                erlaubt& = 0                        No structure übergeben, means no permit to that
                endif                                settle the System-Time = ignoriere Parameter 5

            else

                Result$ = error 7           it get no data receive

            endif

            closesocket(mysocket&)
            WSAClean()

        endif

        if erlaubt&                             Parameter 5 the Unit: settle the System-Time allows

            SetSystemTime(pointer&)
            dummy& = SetLocalTime(pointer&)
            casenot dummy& : Result$ = error 8     Error at settle the system ( local ) Time

        endif

        return Result$

    endproc

 
02/03/09  
 




Andre
Rohland
Nanüchen...

Unit watts 10 time Downloaded, kommentierter View source watts To Disposal set.

really no spotting, Notes o.ä. ?
 
02/04/09  
 




RGH
Hello Andre,

gib whom people still ewas Time, itself so To befassen.
I load often what down, circa then first very plenty later - sometimes are it months - moreover To come, me so To befassen. and manches becomes loaded, comes but for want of opportunity never to that employment. are hold not everything schoolboy, students or pensioner with plenty Time here ...

Greeting
Roland
(the befürchtet, too dereinst as pensioner not so plenty Time to have, How it gladly had and as student not the nötige money having, around the Time so To benefit, How it it then gladly done had)
 
Intel Duo E8400 3,0 GHz / 4 GB RAM / 1000 GB HDD - ATI Radeon HD 4770 512 MB - Windows 7 Home Premium 32Bit - XProfan X4
02/04/09  
 



I lean whom thoughts ex, that Roland ever pensioner is.

@Andre: with the Time go the sure dozens Downloads. nevertheless, we need a further battle plan, plenty plenty More XProfan To win.
 
02/04/09  
 



Funkt. super!
 
02/04/09  
 




Andre
Rohland
O.k., O.k. have I understands...

I wanted to really not rumningeln and drängeln, I had me only a little bit gewundert.
IF having still on my first mail ( View source Gibts on inquire ) speedy with inquire! answered what about me having now somehow a little bit Bammel, that Perhaps something not working.

@Roland: cool, you again personally To reading. Please but not  of middle-aged Profan - Dino from the first mail mislead let, i'm ( with plenty Happiness ) Perhaps in 23 years Member your third category (pensioner) . by then work I yet as coach on Grundschulen with Kindern. Currently are here in Berlin-Brandenburg school holidays, what Perhaps my instantly übermäßigen Zeitfonds declared... .

@IF: it went me really less the number the Downloads, as rather therefore, that the Unit too correctly. funkioniert and useable is.
Concerning battle plan :
is one quite komplexes Topic, on the I thoroughly interested be. suggest, we load this Posting lest, separate make either a new Posting on, or talk us directly by Email. we could so to that example imaginations replace, together above laugh and in the Result Perhaps still a good strategy find... .
 
02/04/09  
 




Andre
Rohland
still another importent Info...

In my Program, in welchem I The Unit use, go any three Zeitserver the Uni Braunschweig quizzed. in the Falles one Mißerfolgs becomes The request any three minutes anew implemented.

After Compile and left to ausführbaren *.exe File could too to 20 minutes yet no link to the Zeitservern manufactured go, though in the Interpreter everything tadellos klappte.

The cause:
I use utterly Care of GDATA (Antivirus + Firewall). After the left with the Runtime-Module blockte The Firewall The link, what tappt im dunkeln me gemeinerweise naturally not indicating... .

Solltet your means such Problems having screen Please first Your Settings for your Antivirusprogramm, or. The Firewall(s).

In my entrapment genügte one plainer Scan with the Antivirus-Komponente of GDATA utterly Care, circa my fertiges Program as vertrauenswürdig einzustufen, thereafter klappte again everything at first attempt.

mfG
André
 
02/12/09  
 




E.T.
Moin,
Have this time ausgegraben, because I to very such a thing Search.
bring but the example somehow not to that walk

or someone 'ne others idea, The System-Time by internet To to put ??

background:
my computer for my Wetterstation has to one Neustart (or. kurzzeitigem blackout) always unsinnige Time-Settings.
well the battery pack there, can itself on 'nem Mini-PC (Orbsmart) neither so simply change).
with Win-own Mitteln komm I do not reliably moreover, The System-Time sure to the computer-Start To to put: time works, öffters but neither.

there The software for my Wetterstation (and Auswertung etc.) eh to the Start of WIN 8.1 of a XProfan-Program the row to launched becomes, was so the thought, still to the started the relevanten programs same The Time before with irgendeinem Server To syncronisieren.
 
Grüße aus Sachsen... Mario
WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte...
06/15/20  
 




Matthias
Arlt
the above-mentioned example wants by me neither so right...
another Possibility bestünde over The Kommandozeile How follows:

net time /setsntp:ptbtime2.ptb.de
w32tm /resync

The Zeitserver is naturally variable (not any functions always).
the can itself then on different point automatisieren.
 
WinXP SP2, Win7 - XProfan 10/11/FreeProfan32 - Xpia
06/15/20  
 




E.T.
Matthias Arlt (15.06.2020)
net time /setsntp:ptbtime2.ptb.de
w32tm /resync


functions neither, as should.
somehow launch my 8.1 whom "Zeitdienst" first etliche Time to the Start / Neustart, the can itself under services neither Change (withal "Start sofort" still a eternity later).
therefore working these Variante neither sure, and success or failure can neither controlled go.
 
XProfan X3
Grüße aus Sachsen... Mario
WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte...
06/15/20  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

16.508 Views

Untitledvor 0 min.
E.T.12/09/22
Georg Teles10/01/22
RAW06/05/22
Member 640534304/16/22
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie