This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create socket | |
| int sock = socket(...); | |
| // send bytes to the socket | |
| send(sock, buffer, ...); | |
| // receive bytes from the socket | |
| recv(sock, buffer, ...); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTTP.get("https://ing.com") | |
| // execution continues without delay | |
| foo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val response = HTTP.get("https://ing.com") | |
| // wait 30 ms | |
| foo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while(1) { | |
| // check all sockets for ready data | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // many_sockets you want to monitor | |
| epoll_ctl(many_sockets); | |
| while(1) { | |
| // blocks if there are is no ready data | |
| int events = epoll_wait(many_sockets) | |
| // handle_events | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while(true) { | |
| // check if there is data available in the socket | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global _start | |
| section .text | |
| _start: mov rax, 1 ; system call for write | |
| mov rdi, 1 ; file handle 1 is stdout | |
| mov rsi, message ; address of string to output | |
| mov rdx, 13 ; number of bytes | |
| syscall ; invoke operating system to do the write | |
| mov rax, 60 ; system call for exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun requestUrl() { | |
| // call network IO | |
| val response = Http.get("https://ing.com") | |
| // wait until response has returned... | |
| processResponse(response) | |
| // continue execution | |
| foo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun requestUrl() { | |
| // call network IO | |
| // when data is ready call .success() | |
| Http | |
| .get("https://ing.com") | |
| .success((response) -> print(response.data)) | |
| // continue execution | |
| foo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while(true) { | |
| // check if one of the sockets in your "interest list" has ready data. | |
| // This call will block if there is no ready data. | |
| int amount_of_new_events = kqueue(events_to_check, new_events, ...) | |
| // When there is ready data in at least one file descriptor, execution continues | |
| // and all the events in `new_events` is checked. | |
| for (int i = 0; i < amount_of_new_events; i++) { | |
| Event event = new_events[i] |
NewerOlder