Skip to main content


developerWorks  >  Linux | Open source  >

Sockets programming in Ruby

Explore Ruby's fundamental sockets interfaces for networking applications

developerWorks

Level: Intermediate

M. Tim Jones (mtj@mtjones.com), Senior Principal Software Engineer, Emulex Corp.

11 Oct 2005

Register now or sign in using your IBM ID and password.

This tutorial shows how to develop sockets-based networking applications using the Ruby language. You learn Ruby basics as well as the most important classes for sockets programming, and then look at a working chat application that illustrates these fundamentals. The tutorial finishes by exploring the higher-level classes that make it easy to build dynamic Web servers, mail servers and clients, and other application-layer protocols.

In this tutorial

  • Review the basics of the sockets API

  • Learn how to build networking applications in Ruby

  • Examine a simple chat server implemented in Ruby

  • Preview some of Ruby's high-level networking classes

Objectives

In this tutorial, you put Ruby to the test by constructing a chat server application that can serve a large and scalable number of clients. By the end of this tutorial, you will know how to use the standard Sockets class to build both client and server applications, as well as how to use classes that simplify sockets programming, including TCPSocket and TCPServer. You will also have tried your hand at building a working, scalable chat server, and you will be familiar with several classes for manipulating application-layer protocols, including HTTP, SMTP, and POP3.


Prerequisites

You should have a basic knowledge of Ruby and basic familiarity with BSD-style sockets.


System requirements

To run the examples in this tutorial, download version 1.8 of Ruby from the Ruby Web site. To build the Ruby interpreter, you need the GNU C compiler (gcc) and configure/make utilities, which are part of any standard GNU/Linux distribution.



Duration

More than two hours


Formats

html, pdf


Learn more

Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed