SIMPOL Documentation

The tcpsocketserver Type

Server programs make use of the tcpsocketserver type for their initialization. The new() method takes a port number and an error object as parameters. The port number must be in the range from 1 through 65535. More importantly it is advisable that the port should be appropriate for the type of service being supplied. If you are implementing a web server, then port 80 is appropriate. Check for the standard port assignments and try to use one that is either appropriate for a standard service or one that is generally unused. Also, unless you are implementing a service that normally uses a port below 1024, it is strongly recommended that a port in the range from 1025-65535 be selected. Ports between 1 and 1024 are in a range that is typically restricted and they may not as easily pass through a firewall.

Assuming that a tcpsocketserver object is successfully returned from the new() method, the only thing left to do is to call the listen() method of the object. The listen method takes four parameters: a function reference, a reference to an object of any type, a timeout value, and an error object. The first of these is a reference to the function that is to be called when a connection is made, the second is an optional reference to any object type. The object would typically be some user-defined datatype holding references to resources that are commonly needed by each connection, such as database table references, a reference to the tcpsocketserver object, etc. The timeout value would probably be set to .inf for most systems. The final parameter should by now be familiar. It is an integer object that will be filled with an error value in case anything fails while trying to listen on the port.