C examples updated to the latest libipc API.
This commit is contained in:
parent
4ba5aa93f3
commit
fba7b11cbe
4 changed files with 34 additions and 5 deletions
27
c/README.md
27
c/README.md
|
|
@ -1,4 +1,5 @@
|
|||
[LibIPC][libipc] C examples: `pong` and `pongd` (simple service and its client, just echoing received messages).
|
||||
[LibIPC][libipc] C examples: `pong` and `pongd` (simple service and its
|
||||
client, just echoing received messages).
|
||||
Implementations are straightforward.
|
||||
|
||||
## Build
|
||||
|
|
@ -14,10 +15,30 @@ make STATIC=1 # Build static executables.
|
|||
## Usage
|
||||
|
||||
```sh
|
||||
./zig-out/bin/pongd # run the service
|
||||
./zig-out/bin/pong # run the client
|
||||
./pongd # run the service
|
||||
./pong # run the client
|
||||
```
|
||||
|
||||
# Using `pong` and `pongd` as debug tools for libipc
|
||||
|
||||
In case you want to use your own version of libipc, first compile your
|
||||
libipc with `--release=fast` or `--release=small` optimization flags
|
||||
(as these options remove some zig-related code in the final binary),
|
||||
then you can compile these tools as is:
|
||||
|
||||
```sh
|
||||
make STATIC=1 LDFLAGS=/path/to/your/libipc.a
|
||||
```
|
||||
|
||||
Then you can run the applications with valgrind if you want:
|
||||
|
||||
```sh
|
||||
make USE_VALGRIND=1 run-server
|
||||
make USE_VALGRIND=1 run-client
|
||||
```
|
||||
|
||||
See the makefiles in `../mk/` for additional options.
|
||||
|
||||
## LICENSE
|
||||
|
||||
ISC
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ build: $(BINS)
|
|||
$(BINS):
|
||||
$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
run-server:
|
||||
$(VALGRIND) ./pongd
|
||||
|
||||
run-client:
|
||||
$(VALGRIND) ./pong
|
||||
|
||||
clean:
|
||||
rm $(BINS) 2>/dev/null
|
||||
|
||||
|
|
|
|||
3
c/pong.c
3
c/pong.c
|
|
@ -58,7 +58,8 @@ int main(void) {
|
|||
size_t count = 0;
|
||||
while(should_continue) {
|
||||
size = MAX_MSG_SIZE;
|
||||
ret = ipc_wait_event (ctx, &event_type, &index, &originfd, message, &size);
|
||||
int newfd;
|
||||
ret = ipc_wait_event (ctx, &event_type, &index, &originfd, &newfd, message, &size);
|
||||
if (ret != 0) {
|
||||
return err(ctx, "Error while waiting for an event.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ int main(int argc, char**argv) {
|
|||
size_t count_timer = 0;
|
||||
while(should_continue) {
|
||||
size = MAX_MSG_SIZE;
|
||||
ret = ipc_wait_event (ctx, &event_type, &index, &originfd, message, &size);
|
||||
int newfd;
|
||||
ret = ipc_wait_event (ctx, &event_type, &index, &originfd, &newfd, message, &size);
|
||||
if (ret != 0) {
|
||||
return err (ctx, "Error while waiting for an event.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue