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

后端 未结 1 1579
栀梦
栀梦 2021-02-14 18:54

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

相关标签:
1条回答
  • 2021-02-14 19:30
    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', ...

    0 讨论(0)
提交回复
热议问题