288
Platforms
©2000-2008 Tibbo Technology Inc.
If what we've just said doesn't ring any bell for you, don't worry.
These, indeed, are very technical things and you don't have to
understand them fully to be able to use the sock object.
"Active opens" for UDP
When you tell an "UDP" socket to connect, the latter will just resolve the IP
address of the target and consider "connection" established.
Do not forget: connection handling is fully asynchronous!
Keep in mind that the sock object handles communications asynchronously. When
the VM executes the
method it does not mean that the connection
is established by the time the VM gets to the next program statement. Executing
sock.connect merely instructs the master process to start establishing the
connection (more on master process and the VM in the
topic). Connection establishment can take some time and your application doesn't
have to wait for that to complete.
topic explains
how to find out actual connection status at any time (see
and
R/O properties).
Asynchronous nature of the sock object has some interesting
implications.
More On the Socket's Asynchronous Nature
topic
contains important information on the subject, so make sure you read
it!
Sending UDP broadcasts
How to send UDP broadcasts
UDP datagrams can be sent as broadcasts. Broadcast, instead of specifying a
particular network host as a destination, targets a group of hosts on the network.
The sock object supports link-level broadcasts. Such broadcast packets
have their destination MAC address set to 255.255.255.255.255.255.
Link-level broadcasts are received by all network hosts connected to
the current network segment. Link-level broadcasts cannot penetrate
routers, bridges, etc.
To make the socket send its outgoing UDP datagrams as broadcasts, set the
property to 1- YES:
...
sock.targetbcast= YES
sock.setdata(
"ABC"
)
'this is explained in 'Working With Buffers' section
sock.send
'this is explained in 'Working With Buffers' section
sock.connect
'broadcast UDP datagram with string 'ABC' will be sent out at
this point
...
330
7
292
355
358
294
359