Skip to content

Conversation

@sehe
Copy link

@sehe sehe commented Feb 9, 2021

Note this is a single commit (20a7b1d) on top of the PR #5

Add a Cmake for easier start-up

To use:

cmake .
make
make test

Run the example in separate terminals:

./examples/server
./examples/client

sehe added 11 commits January 20, 2021 00:55
This can be important. Also, realize that destruction order is the same
in reverse.
Note that there is missin error handling as the TODO already indicated
Avoid non standard code to allow portability.

Made the headers into a named struct and members. Reworded most _data
accesses to use `headers()` accessor.
Adds join to ~msghub_impl
Adds a work_ object to avoid prematurely exiting io_service
Graceful shutdown requires closing the hubconnection and any acceptor if
applicable. Only then will a join() complete.

Actually this needs bit more work, because one does not by default want
to cut operations in the middle of sending output.

I suggest giving `do_close` a bool flag `forced` to indicate whether
pending write operations (operations for which we own the initiative)
are to be forcibly interrupted.

Existing locations to invoke `do_close` in error conditions shall supply
`forced = true`. Other cases should default to `forced = false` so as to
make sure that simple client programs will work as expected:

```c++
    msghub msghub(io_service);
    msghub.connect("localhost", 1334);
    msghub.publish("Publish", "new message");
    //msghub.join(); // implied
```

Here the message should be expected to be delivered, regardless of
timings. Of course barring connectivity issues, in which case
`do_close(forced = true)` should happen because of the error condition.
To use:

    cmake .
    make
    make test

Run the example in separate terminals:

    ./examples/server
    ./examples/client
@sehe sehe force-pushed the cmake branch 2 times, most recently from 4d0fa5a to c6c78cb Compare February 9, 2021 22:26
Somehow the runner was segfaulting with the CMake steps. Didn't want to
find out why, instead used the default runner main with auto test
suites/cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant