Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact
Version 7 (modified by JJR, 14 years ago)
More stuff about networking -- must remember bibliography

Leave Comments, Critiques, and Suggestions Here?

An Introduction to Networking with Tango

Network software development has earned the reputation for not only being a tedious pursuit but also having an alarmingly steep learning curve. There are some significant reasons for why this is the case: one relates to its construction using C language structures, and another concerns its origins from Unix design history.

Over the last few decades, approaches to network programming were introduced using new programming paradigms. Probably the most prominent of these approaches were adapted to use advanced features in languages like Java and C++ (for example: C++'s ACE network framework). A higher level framework and more consistent programming model were intended to produce a less error-prone development cycle and simpler application construction.

Tango seeks to do much the same for the D language by delivering several basic network interface components on which we can build more complicated client or server applications. The design is intended to follow a model consistent with the rest of the library, thus providing a shallower learning curve for the whole. The design of the individual components are also intended to be similar enough to original networking library models to ease the transition for skilled network software developers. D's object oriented features are once again applied to create a framework for logical and concrete network communication.

A History

Berkley Software Distribution Unix made it's imprint in networking history during the last few decades of the twentieth century. BSD Unix, as the academic-originating Unix operating system came to be called, was a direct competitor with Bell Lab's Unix distribution. Bell Lab's Unix was the original design of what became the most popular OS model of the last half a century. Each distribution eventually contributed the majority of the application programming interfaces we use today. Of particular importance was the contribution of networking protocols like TCP/IP. While there have been many influences and contributions from many parties, platforms, and operating systems, this "protocol stack", as the the Unix software layers came to be called, remains the most prevalent.

BSD's style of Unix ended up being adopted by a number of software industry leaders. The two Unix distributions, BSD and Bell Lab's System V, had parted ways early on and were largely incompatible. BSD managed to develop new programming interfaces that became readily adopted in many highly popular server products, the best example perhaps coming from Sun Microsystems ( SunOS ). One of the most important API's to surface from BSD came to be called BSD Sockets. In short order BSD Sockets became practically a standard across many non-BSD Unix distributions as well.

The purpose of BSD Sockets was to create a programming interface that conceptualized a plug-in connection principle for software that communicated across a network. The Socket concept was the high level rendition of network communication. Years later, sockets have become synonymous with network software development, promoted even further by their ready adoption by the ever pervading Linux movement.

All about Networking

The Tango network interface begins with the Socket. The Socket component in Tango is a class that thinly veils a BSD Socket. Since the Tango Socket is merely a BSD Socket with a object oriented interface, it follows that both share a common technical description. Learning about the original socket design is the first step to learning to program a network application or library.

But just before we discuss the Socket component, let us review some basics about networking in general. The first involves the definition of a computer network.

Simply, a network is a collection of computers that communicate with each other through a transmission medium. The communication mechanism must be managed like any other resource to prevent complete pandemonium amongst the connected computers, much like a group of children must be made to talk in turn in order for their speech to be intelligible. Even so, communication is usually managed on several levels using hardware and software protocols. Some protocols help prioritize transmissions; others route the communication to the correct computer; still others help guarantee that connections are established and maintained between specific points.

These protocols are rules that state how network components agree to communicate. They are integrated into hardware or software and are present in multiple levels of any network model.

Networks have come into such prominence that eventually a standard model was designed to describe how to connect combinations of devices for communication. (Complete Encyclopedia of Networking, p 727). The Open Systems Interconnection (OSI Reference Model) is a seven-layer model meant to demonstrate the functional layers of a network and the features available in each layer.

A layer represents a high or low level contributer to the whole network model. For example, a software application with its protocols represents the highest level Application Layer of the OSI (FTP and Telnet are application layer protocols); TCP and UDP protocols represent a middle layer called the Transport Layer; and the transmission line (wired or wireless) represents the the lowest layer called the Physical Layer. (Ibid. p 734) See the figure for a full view of the seven layer model.

The OSI model acts as a guideline only, an abstract breakdown of how network systems operate. Most networks systems with their operating system will implement most of these layers, but they won't be so clearly defined. Some layers may be logically merged for convenience; practicality wins out over theory in these cases.

What the OSI model should indicate is that communication happens in layers. The model helps us understand how network systems work: when we make a connection with another computer, there are several processes that go on, each playing an important part in carrying the payload (the packet) to the destination. Each level generates overhead in carrying the payload; this overhead is generated in exchange for reliability or functional necessity to meet the final purpose. Also realize that each layer at the destination sees its equivalent layer at the source. This means that packets are passed down the layers at the source and back up the layers at the destination; the destination levels strip off the pertinent information designated for their specific layer until the packet is presented in its naked form to the Application Layer. This process will be useful to understand when we discuss the Tango Socket later in this chapter.

There are many physical layouts, hardware arrangements, and network types that are important for the network implementer to understand. But the application programmer's need not deal with these things in most cases. So we will avoid going into any more abstract level details and move directly into what a description of the socket and how it fits into the network model from the programmer's perspective.

Sockets in Detail

... Work in Progress ...

Socket Programming

An excellent guide to low-level socket programming is right here.

Tango exposes this kind of low-level access via, but that is just too low-lowel for general usage. Thus, Tango provides a number of higher level wrappers to make Internet programming more productive.





Uri represents Internet URLs:


This is the Internet equivalent of FileConduit: