Event-driven Model in C with Sockets

后端 未结 5 1399
攒了一身酷
攒了一身酷 2021-01-30 14:40

I am really interested in event-driven programming in C especially with sockets so I am going to dedicate some time doing my researches.

Let\'s assume that I want to bui

5条回答
  •  忘了有多久
    2021-01-30 15:34

    You definitely must read the following: http://www.kegel.com/c10k.html. That page is the perfect overview of event-driven and asynchronous techniques.

    However, a quick & dirty answer: event-driven is neither non-blocking, nor asynchronous.

    Event-driven means, that the process will monitor its file descriptors (and sockets), and act only when some event occurs on some descriptor (events are: data received, error, became writeable, ...).

    BSD sockets have the "select()" function. When called, the OS will monitor the descriptors, and return to the process as soon as some event on one of the descriptors occurs.

    However, the website above has much better descriptions (and details about the different APIs).

提交回复
热议问题