Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 20 in printed book and digital formats -- plus a one-year subscription (beginning with 21.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Recent issues

Article Preview

Buy Now

Issue 3.6


Networking 101

Networking 101

Issue: 3.6 (July/August 2005)
Author: Aaron Ballman
Author Bio: Aaron is the self-appointed head of the networking department at REAL Software. In his spare time he likes to hang out with friends, consume frosty beverages, and build nuclear reactors from Legos.
Article Description: No description available.
Article Length (in bytes): 19,204
Starting Page Number: 27
Article Number: 3612
Related Link(s): None

Excerpt of article text...

Have you ever wanted to add networking capabilities to your application but just didn't know where to start? Or maybe you're interested in advancing your knowledge of how networking works in REALbasic. If that's the case, then you're in the right place! This is the first of four articles on networking with RB which will cover progressively more difficult topics. By the end of it all, you'll be a networking guru!

Lets start off with a few key terms that you will see throughout this discussion. Any terms you see in italics are standard terms that all networking geniuses should know. There's a lot of information to cover, but don't get scared. How about we get started?

The basics

The very first term you are likely to run across in any discussion about networking is socket. A socket is a strictly conceptual entity that is used for all network communications. It isn't persistently stored anywhere on your machine like files are, and it's not a physical object (like a wire or card) installed anywhere. It is simply the term used for the object that the operating system uses for network communications.

A protocol is one way of describing how data will be sent back and forth between two sockets. Basically, it's a standard agreement between two sockets with regards to the way in which the data is going to be sent. For example, the Easy Networking classes (which will be described in a future article) define a proprietary protocol that says each message will be made up of four bytes of length information, four bytes for a command (or message) identification number, and an arbitrary number of bytes of data. Anyone can define a protocol, but there are some standard ones that REALbasic provides for you (such as the TCPSocket and UDPSocket). The former makes use of the TCP protocol which we will be discussing in this article. TCP is the Transmission Control Protocol, which is the basis for most internet traffic. It is a connection-oriented protocol, which means that you need to take steps before you are able to send data back and forth between two sockets. Once two sockets have connected to each other, they are able to send data across the network. A packet is one of the standard units of measurement for sending data across a network. Basically, all information travels in packets across the wire, and how those packets are made depends on the socket protocol you are using. If you are using the TCP protocol, then the packets are generated from the data you send, then sent across the wire with some additional information, and are reassembled on the remote side before being read in.

So how do you specify what machine you want to connect to, or how do you say that you want other machines to connect to you? Every machine on the internet has a specific address that identifies where the machine is, and each machine has another chunk of information that identifies what services it provides. When combined, this information forms a tuple. A tuple consists of two (or more) pieces of information which make up the unique identifier for the machine to establish connections. The first piece of information we are interested in is called an IP Address, which is the location on the internet a particular machine resides. This can either be in dotted-decimal form, like, or can be a domain name, like "www.google.com". In either case, it's a unique identifier that tells you where the machine lives. The other piece of information we are interested in is the port number. A port specifies what service the individual computer is providing. More technically, it's an identifier on the computer's network interface that allows you to have multiple connections coming into and going out of a machine. Port numbers are in the range 1-65535 (0 is reserved for a special meaning), and they are divided into two main classifications. Ports from 1 to 1024 are called well-known ports. These are reserved for servers (computers which are listening for connections), whereas all the other ports are for either servers or clients (machines that connect to servers). When you pick a port to use, you bind to that port to signify that you are using it. Typically, clients don't care about what port they are bound to (the system just picks one for you at random); they only care about what ports servers are bound to. Just keep in mind that if you are the client, you need to specify the server's port number. If you are the server, you need to specify what port clients will be connecting to you on. Another thing to keep in mind about ports is that there can only be one socket at a time bound to any port. Trying to bind two sockets to the same port results in an error.

...End of Excerpt. Please purchase the magazine to read the full article.