> On 03 Mar 2016, at 09:23, stepharo <steph...@free.fr> wrote:
> 
> Hi guys
> 
> for the mooc I would like have a list of how to that students should look in 
> the system and implement.
> The idea is to show to the participants that Pharo is open and that they can 
> find information.
> For example,
>        - extracting a sprite from a png file
>        - access a time service of the web

Time is soo simple that there is no real need for a true web service and such a 
service would be trivial anyway (yet I did not find any public/free ones).

Here is one way to do it:

| stream unixTime |
stream := nil.
[
        "RFC 868 TCP protocol https://en.wikipedia.org/wiki/Time_Protocol " 
        stream := ZdcSocketStream openConnectionToHostNamed: 'time.nist.gov' 
port: 37.
        unixTime := (stream next: 4) asInteger ]
        ensure: [ stream ifNotNil: [ [ stream close ] on: Error do: [] ] ].
DateAndTime fromUnixTime: unixTime.


The real stuff is SNTP though

        http://en.wikipedia.org/wiki/Network_Time_Protocol
        http://tools.ietf.org/html/rfc2030

which is implemented in ZTimestamp and which can do much more:

  ZTimestampSNTPClient new remoteClock.

Sven

> Now I would love to get your ideas and their solution.
> 
> Stef
> 
> 
> 


Reply via email to