|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.
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: