276
Platforms
©2000-2008 Tibbo Technology Inc.
Anatomy of a Socket
A socket is composed of a send/receive logic that actually handles UDP, TCP
(including HTTP) communications, and of 6 buffers. Each socket is capable of
maintaining one connection with another node (host) on a network.
The socket object contains properties, methods and events which relate both to the
buffers and the send/receive logic.
The buffers available are:
The RX buffer, which stores data incoming from the host on the other side of a
connection (this buffer doesn't have to be used for
).
The TX buffer, which stores data which is due for sending to the host on the
other side of a connection (for HTTP connection, this buffer can store both the
request and the reply).
The TX2 buffer, which is used internally, and only when
are enabled.
The CMD buffer, which is used to store incoming inband commands (messages).
It is used only when inband commands are enabled.
The RPL buffer, which is used to store outgoing inband replies (messages). It is
used only when inband commands are enabled.
The VAR buffer, which is used to store
request string. It is needed only
when the socket is in the HTTP mode.
Socket Selection
TiOS supports up to 16 sockets, but there may be platforms with less than 16
sockets available. You can obtain the number of sockets available for your platform
using the
property.
Since there can be multiple sockets, you must state which socket are you referring
to when changing properties or invoking methods. This is done using the
property. For example:
sock.protocol =
1
Can you tell what socket the statement above applies to? Neither can the platform.
Thus, the correct syntax would be:
sock.num =
0
sock.protocol =
1
Now the platform knows which socket you're working with. Once you have set the
socket selector (using sock.num), every socket-specific method and property after
that point is taken to refer to that socket. Thus:
277
297
309
314
314
309
314
341
340