![]() Whenever a client sends a request, Node.js will parse it in the background and call our anonymous function and pass the request object. That is because we still have a callback registered via createServer (the function we passed). In this case, however, we don't have to deal with thread management and we always stay with one thread, thanks to callbacks and the event loop.Īs mentioned, listen will return immediately, but - although there's no code following our listen call - the application won't exit immediately. At this point, the latest, we'd have to switch to multi-threading, as otherwise we could handle exactly one connection at a time. In most other languages, we'd usually have an accept function/method, which would block our thread and return the connection socket of the connecting client. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |