liblooptc is a C library designed for facilitating inter-thread communication using loopback connections. It provides functions to create loopback channels, read messages from these channels, and write messages to them. The library is intended for scenarios where multiple threads need to communicate with each other within the same process.
- Create loopback channels for inter-thread communication.
- Read messages from loopback channels.
- Write messages to loopback channels.
To use liblooptc in your project, follow these steps:
- Clone the repository:
git clone <repository-url>
- Include the header file
looptc.h
in your source code:
#include "looptc.h"
- Compile your source code with
liblooptc.a
:
gcc -o your_program your_program.c -L/path/to/liblooptc -llooptc
- Ensure that liblooptc.a is present in your library path.
- Start using the provided functions in your code.
You have looptc_example.c
in this repository... if you want a simple one:
#include <stdio.h>
#include "looptc.h"
int main() {
int channel = looptc_create_new_channel();
if (channel < 0) {
fprintf(stderr, "Error creating channel\n");
return EXIT_FAILURE;
}
char message[] = "Hello, world!";
if (looptc_write_msg(channel, message, sizeof(message)) < 0) {
fprintf(stderr, "Error writing message\n");
return EXIT_FAILURE;
}
char buffer[256];
if (looptc_read_msg(channel, buffer, sizeof(buffer)) < 0) {
fprintf(stderr, "Error reading message\n");
return EXIT_FAILURE;
}
printf("Received message: %s\n", buffer);
return EXIT_SUCCESS;
}
This project is licensed under the Public Domain.
liblooptc is developed by Abel Romero Pérez.