|Top Previous Next|
This is the sockets object. It allows you to maintain up to 16 simultaneous UDP or TCP ("normal" or HTTP) connections (actual number supported by the platform may be lower, due to memory constraints).
Very commonly, each connection is called a "socket". This is the term we will use as well. On other programming systems, sockets are often dynamic, created and destroyed as needed. With TiOS, you receive a preset number of sockets which have already been created for you, and just use them. A socket may be idle, but it will still be there.
Individual sockets have all the traditional settings you would expect to find, such as destination port number, protocol, etc. At the same time, their functionality goes significantly beyond what you usually find, and includes a lot of additional features that significantly lower the amount of code you need to write. For example, you can restrict incoming connections to your device, automatically filter out certain messages within the TCP data stream, etc.
The sockets object also implements webserver (HTTP) functionality. Each socket can carry a "normal" data connection or be in the HTTP mode.
Currently, the socket object can only access first 65534 bytes of each HTML file, even if the actual file is larger! Make sure that all HTML files in your project are not larger than 65534 bytes. This is not to be confused with the size of HTTP output generated by the file. A very large output can be generated by a small HTML file (due to dynamic data)- and that is OK. What's important is that the size of each HTML file in your project does not exceed 65534 bytes.
The sock object should not be confused with objects used to represent actual network interfaces, such as the net object which represents the Ethernet interface. The socket object is responsible for actual IP (TCP or UDP) communications -- it doesn't matter which interface these communications are effected through. Therefore, this is not the right place to look for a property such as 'IP address'. This is an attribute of a particular network interface.
Follows is the list of features offered by each socket of the sock object:
•Support for UDP, TCP and HTTP protocols (this is a submode of TCP).
•An extensive set of properties that define which hosts can connect to the socket, whether broadcasts are supported, which listening ports are associated with the socket, etc.
•Support for automatic processing of inband commands-- messages that are passed within the TCP data stream.
•Detailed socket state reporting with 30 different states supported!
•Fully asynchronous operation with separate "data arrival" and "data sent" events.
•Automatic data overrun detection on the RX buffer.
•Adjustable receive (RX), transmit (TX), and other buffer sizes for optimal RAM utilization.
•Buffer shorting feature for fast data exchange between the sock object and other objects (such as the ser object) that support standard Tibbo BASIC data buffers.