Understanding the Server Architecture (Internet Pack)

From RemObjects Software

Jump to: navigation, search

This is a Internet Pack How To entry
Feel free to add your notes to this topic below.



The following topic will give you a brief insight into the inner workings of the IP server architecture. You won't necessarily need this information if you are just planning to use the IP components, but some understanding of these concepts is essential if you want to expand IP with your own server component implementations.

The server architecture is split across several classes, all of which play small but significant roles in the overall process. Of these classes, the two that you will most likely be creating descendants from are Server and Worker. The paragraphs examine each class in some detail and explain how they fit together

Server

Server is the base component that encapsulates the concept of a server or service - it will provide one or more Ports for the client to connect to, accept incoming connections and delegate processing of these. The Server component itself does little more then just host the related subcomponents that do the actual processing.

ServerBinding

Every server has one or more Bindings, implemented by the ServerBinding class. A binding defines a local TCP/IP EndPoint that will be listening to incoming connections. All Bindings are active on a Port, and Bindings can optionally be tied to a specific local IP address. This allows you to tightly control what network interfaces your server will be available on.

When activating your server (see Opening a Server), it will automatically loop over all it's Bindings and Bind each of them to the specified EndPoint. Calling the Bind method will in turn open a server socket on the network adapter and create a Listener object and one or more listener threads, each of which will now be ready to accept incoming connections from a client.

Listener

Once started, each listener thread will run the Listen method of it's Listener. This method will keep monitoring the active socket for incoming connections. When a connection comes in, a Worker thread is spawned to process the connection, and the Listener will immediately go back to monitoring the socket for new connections. This allows a high number of simultaneous or consecutive connections to be handled.

Worker

Worker is a very simple class, really. It gets a reference to a Connection object from the Listener, and provide an (abstract) method called DoWork that will be called to process the connection. When implementing a custom server component, you will usually create a descendant of Worker and override the DoWork method to implement your protocol.


See Also


Product: RemObjects Internet Pack
Current version: Internet Pack 'Vinci' (2.0)

ListsGlossaryFeaturesHow ToComponentsToolsSamplesArticlesArchitectureIssues

Personal tools