O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tk-Based Peer Chat

Back on Day 19 we toyed with the idea of chat scripts allowing people to type messages to each other over the Internet. Our implementation at the time was really barely functional; its main drawback was that any conversation had to be sequential, meaning that the parties—let's refer them to Alice and Bob—had to take turns speaking. Once Bob had sent a message, he was not allowed to send another one until Alice replied. Today we remedy that problem by resolving two little problems.

  • When Alice is typing in a message, how can she receive a message from Bob? It would seem her script needs to be evaluating two separate gets expressions simultaneously, one of them referring to her keyboard and the other to a network socket.

  • If a message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required