NTP Server

Few days ago I stumbled upon problem. I had three Windows 7 computers without Internet access and I needed time synchronization between them. It wasn’t really important that time is correct - it was important that time is same. Solution was simple - just make one of computers NTP server and let others synchronize to it (using standard Windows time synchronization). While Windows 7 synchronizes time perfectly over Internet and/or when you are member of domain, it does not include NTP server.

As I tried to install some other software it became clear that I need to stop and DISABLE “Windows Time” service. NTP servers can only work if they can use UDP port 123. As long as “Windows Time” service is running that port is taken by it. For my scenario this service does nothing so disabling it caused no problems.

As I tried few NTP server solutions I got more and more desperate - either they weren’t free (yes, I am cheap bastard) or they would not work as service under Windows 7. After some time I just decided to make my own program. How hard can it be?

While I consider most of RFCs technical descriptions pure beauty, somebody made a mess of this one. All information was there, how to synchronize, which algorithms to use, probably even genealogy of authors - only thing not there was pure and simple ASCII format of UDP packet. Fortunately authors of SNTP (which is mostly compatible with NTP) did much better work with it. That combined with old pal WireShark made this program possible.

As any program that is written in one afternoon, this one has fair share of things not done. First of all, this program was only tested with Windows XP and Windows 7 as clients. While other versions should work, I spent no time in actually testing it.

This server is also not fully NTP compliant. All fields are there and all clients will consider it valid time source but stratum, precision, root delay and root dispersion numbers are just hard-coded instead of calculated. This should present no trouble in local network and if precision in seconds is satisfactory, but it is definitely not time server you would use if every microsecond is important.

Program requires .NET 2.0 and there is no setup. When you extract it to desired folder first order of day is performing installation from administrator prompt (cmd with Run as Administrator is fine). There we just run program with /install as parameter (“tempora.exe /install”) and service will be installed and started (if you remembered to DISABLE “Windows Time” service first). As long as you don’t uninstall it (“tempora.exe /uninstall”) it will start at each startup and it will return current time to all it’s clients.

Download is here.

P.S. Do not forget to DISABLE “Windows Time” service. ;)

[2015-04-25: Program is available on GitHub]

IsNullOrWhiteSpace

When one deals with user input, it is quite useful to check whether user entered anything. Definition of “anything” is not necessarily same for developer and user.

Quite often user will consider one accidental space to be nothing at all. To implement proper check developer would need something like this:

if (string.IsNullOrEmpty(text) || (text.Trim().Length == 0)) {
    //Text is empty.
} else {
    //Text is not empty.
}

Code is not difficult and it is pretty obvious. Hard part (at least for me) is remembering to add this text.Trim().Length==0 condition. Some time I just forget.

.NET 4.0 brings little bit of syntactic sugar in this area:

if (string.IsNullOrWhiteSpace(text)) {

It is basically same code - just a little bit shorter and, thanks to IntelliSense, much easier to remember.

WebMatrix

Illustration

All those interested in ASP.NET might benefit from newest Microsoft toy. It is called WebMatrix and it is currently available as a beta. It brings to table everything lightweight web development needs: easy syntax (ASP.NET Razor), small database (well known SQL Server Compact Edition) and decent web server (IIS Developer Express). Those interested might as well check video presentation.

For me IIS Developer Express is probably best thing in this package. It is simple web server that does not need ninja to configure it properly. Works with any recent Windows system (yes, even XP is supported) and all that while having almost complete compatibility with full IIS Server. That is quite a feat since all IIS 7 modules are also supported alongside whole IIS 7 extensibility model.

All that and it needs only some space on hard drive and standard user privileges for both running and debugging.

Naming Issues

Illustration

I had to install SQL Server 2008 R2 on Windows Server 2003. As soon as install started, I was greeted with message that Windows Installer 3.1 and .NET Framework 3.5 are missing (yes, it was quite an old installation). Fortunately links were provided and I was ready to continue install.

After checking system requirements, SQL Server had another surprise for me - it needed PowerShell 2.0. Although it was annoying that I haven’t got this error before, I just went to big evil Internet to download it.

To my surprise I could not find direct link to PowerShell 2.0 download. There was a lot of talk about it, quite a few links to PowerShell 1.0 - everything but quick link toward PowerShell 2.0. After restricting search to Microsoft only, problem was found.

For some reason Microsoft decided to pack PowerShell 2.0 with some additional tools and call it a Windows Management Framework update. Following links on that page finally brought me to download containing PowerShell 2.0 (among other things).

KulenDayz 2010

Illustration

There is still hope in this world. KulenDayz 2010 conference will be held this year at little bit later date. As usual it will be three-day event starting on Friday evening (2009-09-03) and ending on Sunday afternoon (2010-09-05).

While I did give presentation on KulenDayz 2009, I am not sure whether I will give one this year but I am sure that I will attend anyhow.

Since conference will be held in Beli Manastir, Croatia I do understand that it is probably somewhat inconvenient to 97% of my foreign readers but I can promise that anyone coming will not be sorry.

Conference is small, friendly, free and you have a chance to meet me. It does not get better than that. :)