Blame


1 71d9d1b3 2023-12-22 op // This is free and unencumbered software released into the public domain.
2 71d9d1b3 2023-12-22 op //
3 71d9d1b3 2023-12-22 op // Anyone is free to copy, modify, publish, use, compile, sell, or
4 71d9d1b3 2023-12-22 op // distribute this software, either in source code form or as a compiled
5 71d9d1b3 2023-12-22 op // binary, for any purpose, commercial or non-commercial, and by any
6 71d9d1b3 2023-12-22 op // means.
7 71d9d1b3 2023-12-22 op //
8 71d9d1b3 2023-12-22 op // In jurisdictions that recognize copyright laws, the author or authors
9 71d9d1b3 2023-12-22 op // of this software dedicate any and all copyright interest in the
10 71d9d1b3 2023-12-22 op // software to the public domain. We make this dedication for the benefit
11 71d9d1b3 2023-12-22 op // of the public at large and to the detriment of our heirs and
12 71d9d1b3 2023-12-22 op // successors. We intend this dedication to be an overt act of
13 71d9d1b3 2023-12-22 op // relinquishment in perpetuity of all present and future rights to this
14 71d9d1b3 2023-12-22 op // software under copyright law.
15 71d9d1b3 2023-12-22 op //
16 71d9d1b3 2023-12-22 op // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 71d9d1b3 2023-12-22 op // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 71d9d1b3 2023-12-22 op // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 71d9d1b3 2023-12-22 op // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 71d9d1b3 2023-12-22 op // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 71d9d1b3 2023-12-22 op // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 71d9d1b3 2023-12-22 op // OTHER DEALINGS IN THE SOFTWARE.
23 71d9d1b3 2023-12-22 op
24 71d9d1b3 2023-12-22 op use io;
25 71d9d1b3 2023-12-22 op use net::dns;
26 71d9d1b3 2023-12-22 op use strings;
27 71d9d1b3 2023-12-22 op
28 71d9d1b3 2023-12-22 op use ev;
29 71d9d1b3 2023-12-22 op
30 71d9d1b3 2023-12-22 op // XXX generic listen would be very handy!
31 71d9d1b3 2023-12-22 op // something like: http::listen("localhost:8080") or maybe even
32 71d9d1b3 2023-12-22 op // http::listen("unix:/run/foo.sock")
33 71d9d1b3 2023-12-22 op
34 71d9d1b3 2023-12-22 op export fn listen_sock(f: io::file, mux: nullable *mux) void = {
35 71d9d1b3 2023-12-22 op ev::add(f, ev::READ, &acceptconn, match(mux) {
36 71d9d1b3 2023-12-22 op case null => yield &global;
37 71d9d1b3 2023-12-22 op case => yield mux;
38 71d9d1b3 2023-12-22 op });
39 71d9d1b3 2023-12-22 op };