279
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
the packet and the sender won't know whether the packet was received or not.
Each UDP datagram lives its own life and you are responsible for dividing your data
into chunks of reasonable size and sending it in separate datagrams. There is no
connection establishment or termination on UDP- the datagram can be sent
instantly, without any preparation.
Unline TCP, the UDP is not point-to-point. For example, several hosts can send the
datagrams to the same socket of your device- and all of them can be accepted- a
situation that is impossible with TCP. There is also an option to broadcast the
datagram to all hosts connected to the same network segment- something that is
also impossible with TCP.
And now to UDP "connections"...
This said, it should come as a bit of a surprise that we will now turn 180 degrees
and start talking about UDP "connections". Didn't we just say that there is no such
thing? Well, yes and no. On the physical network there is, indeed, no such thing.
However, on our socket object level we have deliberately made UDP
communications look more like TCP connections. And, since the UDP "connection"
is nothing more than our sock object's abstraction, we use the word "connection"
in quotation marks.
We consider an active open to have been performed when our host has sent the
first UDP datagram to the destination. A passive open is when we have received
the first incoming UDP datagram from another host (provided that this datagram
was accepted- more on that in
).
There is no graceful disconnect for UDP connections. The connection can only be
discarded (our host "forgets" about it). The UDP connection can also
.
Accepting Incoming Connections
Master switch for incoming connections
It is possible to globally enable or disable acceptance of incoming connections on
all sockets, irregardless of the setup of individual sockets. This is done using the
property. By default, this property is set to 1- YES.
Defining who can connect to your socket
("incoming connections mode") property allows you do
define whether incoming connections will be accepted and, if yes, from who. By
default (0- PL_SOCK_INCONMODE_NONE), incoming connections are not allowed
at all. For TCP this means that incoming connection requests will be rejected. For
UDP, incoming datagrams will simply be ignored.
If you don't mind to accept an incoming connection from any host/port then set
the
= 3- PL_SOCK_INCONMODE_ANY_IP_ANY_PORT. This way,
whoever wants to connect to your socket will be able to do so as long as this party
is using correct transport protocol (you define this through the
property) and is connecting to the right port number (more on this below).
If you are only interested in accepting connections from a particular host on the
network then set
= 2-
PL_SOCK_INCONMODE_SPECIFIC_IP_ANY_PORT. This way, only the host with IP
matching the one defined by the
property will be able to connect
to your socket.
You can restrict things further and demand that not only the IP of the other host
must match the one you set in
property, but also the port from
279
290
337
338
338
345
338
359
359