ASYNCHRONOUS DATA COMMUNICATION
In Asynchronous Transmission, a special bit is inserted at the beginning and end of a character transmission and thus allows the receiver to understand what was actually transmitted. Imagine a sequence of data that needs to be transmitted. Each data block has a flag (control species) that informs where this block begins and ends, in addition to the position in the transmitted data sequence.
With this, the data can be transmitted in any order and it is up to the receiver to interpret this information and put it in the right place. However, the disadvantage is the misuse of the channel, as the characters are transmitted irregularly, in addition to a high overhead (the control bits that are added at the beginning and end of the character), which causes a low efficiency in data transmission.
SYNCHRONOUS DATA COMMUNICATION
In synchronous data communication, the transmitting device and the receiving device shall be in a state of sync before the communication starts and remain in sync during transmission. Imagine the same data sequence that needs to be transmitted synchronously. Each block of information is transmitted and received in a well-defined instant and known by the transmitter and receiver, that is, these have to be synchronized. When a block is sent, the receiver is locked and can only send another block when the first one is received by the receiver.
Pros and cons
Asynchronous transfers are usually faster than synchronous transfers. This is due to the fact that there is no time to coordinate the transmission. However, due to this, more errors tend to occur in asynchronous transfers. If many errors occur, this can invalidate the time saved with the initial time of setting the parameters because the receiver will have to take measures to correct the errors.
Usages
Asynchronous transfers work well in situations where the exchange takes place over a reliable physical medium, such as optical fiber or coaxial cable, for example. This helps minimize transmission errors, so time saved with setting parameters results in faster transfer from the end-user’s point of view. Synchronous transfers work well for less reliable media such as electrical wires or radio signals. Here, it is worth taking longer to coordinate the details of the transfer, because this compensates for the mistakes made in the physical environment.
Example with ajax
Running asynchronously
$(function(){
var call = $.ajax({
url: "controller/action",
dataType: "json",
}).responseText;
alert(call);
});
This function will make the Request and continue processing, the attribute responseText
will not get the result of processing, because it does not matter if it is finished or not, we are working without synchrony.
Running in a synchronous way
$(function(){
var call = $.ajax({
async: false,
url: "arquivo.php",
dataType: "json",
}).responseText;
alert(call);
});
This time the program will wait for the response to return to continue processing, assuming that any JSON server comes back
Sources:
differences-between-requisicoes-synchronous-and-asynchronous-with-ajax
data-synchronous-x-asynchronous communication
Better answer. No doubt...
– Lollipop