D
D
Dmitry Matveev2017-01-16 23:42:39
Python
Dmitry Matveev, 2017-01-16 23:42:39

What is an asynchronous socket?

Hello. I can not understand how an asynchronous request is implemented. I know that an asynchronous request does not block the program, it continues to work. But this is similar to multireading and multiprocessing. Here I have a question. Multithreading = asynchronous socket?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2017-01-16
@DmMatveev

no, there is no equivalence between multithreading and asynchronous socket.
I will try to explain the essence of an asynchronous socket with a simple example.
you come to the tray to buy mineral water, but it is not there, but the saleswoman says that they will bring it soon.
possible options for your answer:
1) "I'll wait" - synchronous socket, the program waits until a message arrives.
1.5) "they don't deliver something for a long time, I'm tired of waiting,
I 'm leaving" - a synchronous socket with a
timeout how, brought? yes? well, that's great, I'm taking it" - asynchronous socket, another attempt to receive data, this time successful
3) "hello, Vovan, I'm waiting for a mineral water, I'll be back later, work, don't be distracted" - synchronous socket + multithreading. one thread is waiting to receive data, another thread is working
3.5) "Vovan, there is no mineral water here yet, I'll be back" - multithreading + asynchronous sockets. several threads work simultaneously, they do not block on receiving data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question