Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between synchronous and asynchronous transmission in TCP/ IP socket programming?

I am new to C++ and I am trying to develop a client-server application based on the boost::asio library. I am (still) not able to understand properly the difference between sync and async modes. I've previously studied web protocol services such as HTTP and AJAX. From this explanation, it's clear that HTTP is synchronous and AJAX is asynchronous. What is the difference in TCP socket communication in terms of sync and async? And which mode is better from the perspective of enterprise-level multi-threaded application development, and why?

As I understand synchronous mode, the client blocks for a while until it receives the packet/ data message from the server. And in async mode, the client carries out another operation without blocking the current operation. Why is this different? Is async synonymous with UDP? It seems it doesn't care if it receives transmission acknowledgement.

like image 980
abhi abhi Avatar asked Jul 05 '13 05:07

abhi abhi


People also ask

What is the difference between synchronous and Asynchronous Transmission?

Synchronous transmission is faster, as a common clock is shared by the sender and receiver. Asynchronous transmission is slower as each character has its own start and stop bit.

What is the difference between synchronous sockets and asynchronous sockets?

As I understand synchronous mode, the client blocks for a while until it receives the packet/ data message from the server. And in async mode, the client carries out another operation without blocking the current operation.

What's the difference between synchronous and asynchronous?

The key difference between synchronous and asynchronous communication is synchronous communications are scheduled, real-time interactions by phone, video, or in-person. Asynchronous communication happens on your own time and doesn't need scheduling.

What is the main difference between synchronous and Asynchronous Transmission and CQ?

The main difference between synchronous and asynchronous transmission is that the clocking is derived from the data in synchronous transmission and it is absent in asynchronous transmission.


1 Answers

  1. TCP transmission is always asynchronous. What's synchronous or asynchronous is the behaviour of the API. A synchronous API does things while you call it: for example, send() moves data to the TCP send buffer and returns when it is done. An asynchronous API starts when you call it, executes independently after it returns to you, and calls you back or provides an interrogable handle via which completion is notified.

  2. HTTP is synchronous in the sense that you send a request, receive a response, display or process the response, all in that order.

  3. Ajax is asynchronous only in the sense that it operates independently of the page request/response cycle in the surrounding HTTP request. It's a poor choice of terminology. It would have been better to use a term like 'nested', 'out of band', ...

like image 134
user207421 Avatar answered Jun 05 '23 02:06

user207421