Note that there are some explanatory texts on larger screens.

plurals
  1. POData-driven approach to networking in C. This can't be new?
    primarykey
    data
    text
    <p>I'd like to know whether something like this has been done before:</p> <p>I've recently started work on a networking library in C. The library maintains a set of sockets, each of which is associated with two FIFO byte streams, input and output.</p> <p>A developer using the library is expected to register some callbacks, consisting of a recognizer function and a handler function. If new data arrives on a socket (i.e. the input stream), every recognizer is called. If one of the recognizers finds a matching portion of data, its associated handler is called, consuming the data and possibly queuing new data on the socket's output stream, scheduled to be transmitted later on.</p> <p>Here's an example to make clear how the library is used:</p> <pre><code>// create client socket client = nc_create(NC_CLIENT); // register some callback functions that you'll have to supply yourself nc_register_callback(client, &amp;is_login, &amp;on_login); nc_register_callback(client, &amp;is_password, &amp;on_password); // connect to server nc_dial(client, "www.google.com", "23"); // start main loop (we might as well have more than one connection here) nc_talk(); </code></pre> <p>To me, this is the most obvious way to write a general purpose networking library in C. I did some research using Google, but I wasn't able to find something similar written in C. But it's hard to believe that I'm the first one that implements this approach.</p> <p><strong>Are there other data-driven general purpose C networking libraries like this out there? <br />Would you use them?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload