UDPSocket


User Datagram Protocol (UDP) networks work a little differently than TCP networks do. Whereas a TCP network guarantees that all the data you send to another computer will arrive there, a UDP network does not. For TCP to be so error proof, it takes up a lot of overhead and makes the overall process slower. Because you do not have the same guarantee with UDP, it is a much faster protocol. The caveat is that your application must be able to withstand the loss of data and still keep running. When you call the LookupDNSaddress method in the System.Network object, you are using UDP to make a call to a DNS server. Because the request is so simple, UDP is appropriate. If data is missing, you can send another request. Streaming video and audio servers also use UDP because performance is more important than rock-solid reliability for the transmission of each packet.

UDPSocket Class

Properties

UDPSocket.BroadcastAddress as String (Read Only) UDPSocket.PacketsAvailable as Integer (Read Only) UDPSocket.PacketsLeftToSend as Integer (Read Only) UDPSocket.RouterHops as Integer UDPSocket.SendToSelf as Boolean


Methods

UDPSocket.JoinMulticastGroup(Group as String) as Boolean UDPSocket.LeaveMulticastGroup(Group as String) UDPSocket.Read([Encoding as TextEncoding]) as Datagram UDPSocket.Write(Data as Datagram) UDPSocket.Write(Address as String, Data as String)


Datagram

The Datagram class is a simple class with three properties, and it represents the packet of data used by UDP networks. If you were to actually look at the data in a Datagram, you would see that it contains a source port, a destination port number, the length of the Datagram, a checksum for the data itself to ensure that it hasn't been corrupted, followed by the data. The class provided by REALbasic provides a simpler interface, and the available properties include the port, the data itself that is wrapped in the datagram, and the address (either a domain name or IP address). The property has a different meaning, depending on whether you are sending or receiving data. If you are sending data, it contains the number of the Port on the machine the data is being sent to. Otherwise, it contains the number of the Port it is listening to.

Datagram.Address as String Datagram.Data as String Datagram.Port as Integer





REALbasic Cross-Platform Application Development
REALbasic Cross-Platform Application Development
ISBN: 0672328135
EAN: 2147483647
Year: 2004
Pages: 149

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net