iNTERFACEWARE Products Manual > Installing and Using Chameleon > Language API Documentation > Chameleon Networking Components > General Pointers Regarding Asynchronous Programming |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
Asynchronous communication can make for a very efficient use of system resources. Rather than having to wait for long blocking operations to complete, an asynchronous application does not need to wait and can instead be doing other work. However, this means that an asynchronous program usually has to maintain some state information in order to correctly respond to the events that it receives. It also means that operations cannot be performed sequentially. A good example is when a LLP client issues a connection request. Until the request is completed and an onConnect event is received, it is not safe to try and send data via the connection. A correctly implemented LLP client should wait for the LLP OnConnect event before sending data. Another example of a problem with asynchronous network programming is that networking conditions can change over while an application is processing a previous event. For instance, if a client connects to a server it may receive an onConnect event; in the meantime, that server may have disconnected, which means that if the client attempts to send data to the server, a networking error will arise. A correctly written LLP client or server should gracefully handle networking errors at any time.
|