ZZüy: A Lesson in Perseverance

afisxisto1 pts0 comments

ZZüy – A Lesson In Perseverance

ZZüy – A Lesson In Perseverance

I remember when I was first introduced to programming by way of watching my older step brother type the<br>then–very–confusing words gosub and rem onto a bright blue screen. It was<br>exciting. I had no idea what this cryptic language did but I was definitely hooked.

As time went on we got a family PC and my first attempt at programming it wasn't exactly successful. As<br>it turned out, you couldn't put BASIC in .html files, which seemed like such a good idea at the time. I<br>quickly realised I had a lot to learn and decided I'd learn a language that I could use on the PC.

C was nothing like BASIC. It was far more exciting and looked much cooler with all its obscure syntax<br>and low level semantics. As I started to understand things like files and sockets I became fascinated<br>with the idea that I could build programs for other people to use.

After playing with C for a few months I felt confident enough to build something real with it, and it<br>just so happened I had an idea I was pretty excited about. I wanted to build a simple tool that allowed<br>two people write code together over the Internet.

There'd be two boxes. You would type your code into the box on the left, hit send and your partner would<br>see your code in their right hand box. They could copy it across, amend it and hit send to send it back.<br>I distinctly remember being in awe of the fact that by using a TCP socket for sending data, the other<br>person could be on the other side of the world and this would still work – much more fun than BASIC.

So I got cosy with socket(), listen(), bind(),<br>connect(), send() and recv(). A few weeks later I had an early<br>version working and I couldn't wait to test it. It worked perfectly over localhost, but I wanted to see<br>this work over the freaking phone line!

Fortunately my good friend Jacob was on hand to help. I sent him over the wonderfully small executable<br>and gave him my IP address to connect to. I honestly could not believe it when he connected and his code<br>appeared on my screen. I made a few changes and sent it back. It was awesome!

But then something weird happened.

Jacob's code had a series of ZZüy characters at the end. They disappeared on the next update, but then<br>came back. I asked him about the strange characters I was seeing, but he couldn't see them. None of his<br>code was being lost, but these extra characters were becoming very annoying.

Over the next day or two I trawled through the code line by line, desperately trying to work out how<br>these extra characters might occur. It was tiring, and each time I thought I had found the issue, as if<br>by magic, there they were again. I came to passionately hate the sequence of characters ZZüy. I think I<br>still do. I'm biting on my fist right now.

It was actually a little soul destroying each time we retested a potential fix only to find it was still<br>screwed, because after seeing those damn ZZüy characters come back, I had nothing. I had to go back<br>through the process and find some other explanation. I like to consider myself an optimist, but a real<br>test of that is whether you're still optimistic when you have nothing.

After another 10 or so different attempts I finally stumbled upon it. This time, I was absolutely<br>convinced. I had been reading an article about string buffers in C when it mentioned zero–termination,<br>and that's when it hit me. A string buffer needs to contain a zero character to signify the end of the<br>data. It finally all made sense. Suddenly I could imagine how strlen() might work by<br>counting until it found the zero. Suddenly I knew what the Hungarian word psz meant. And,<br>of course, I was seeing random extra characters because the displaying of the buffer didn't know when to<br>stop reading because there was no zero. Oh yes – this time I had definitely nailed it.

So I took the return value from recv() – the total number of bytes received – and used it<br>as an index into the buffer to add the zero terminator. I compiled. I linked. Well, those happened<br>together but I'm trying to build dramatic effect. I took the new executable and sent it across to Jacob.<br>And then I waited.

A minute later he connected and over came his code. His particular choice of sample code this time<br>caused a scroll bar to appear, but were those pesky ZZüy characters still there? Surely they were gone<br>now that the buffer had been zero terminated. Surely.

I scrolled to the bottom of the box praying that I wouldn't see them. But the bastards, in all their<br>glory, were still there. A group of 16 ZZüy characters staring back at me saying “nice try, but better<br>luck next time loser”. I couldn't believe that I'd failed yet again. Back to the drawing board.

The next few hours were shared between outbursts of crying and trying every shot–in–the–dark approach I<br>could come up with to prevent ZZüy from ruining my life. But I persevered, and herein lies my point.

When Einstein was asked why he was so smart, he answered:

It's not that...

code characters time back still zero

Related Articles