OYAMO is a lightweight library for developing server-client applications using TCP/IP in C. It provides a simple API for creating and managing connections, sending and receiving data, and handling events.
- gcc, clang, or another C compiler
- Make
- libuuid1
- json-c
- Easy-to-use API for creating and managing connections
- Support for multiple client connections
- Support for threading
- JSON support for sending structured data
- Custom event system for handling connections, disconnections, and incoming messages
Here is a simple example of a server application using OYAMO:
#include <oyamo/server.h>
void on_connect(void *client)
{
oyamo_message_T *message = oyamo_message_create("route", "operation");
json_object_object_add(message->parameters, "message", json_object_new_string("Hello from the OYAMO server!"));
oyamo_server_send_message_to_client(message, client);
}
int main()
{
// Enable verbose logging
oyamo_set_verbose(OYAMO_VERBOSE_ALL);
// Initialize the OYAMO server
oyamo_server_init();
// Set the server configuration
oyamo_server_config_T *config = oyamo_server_get_default_config("0.0.0.0", 8031);
config->address = "0.0.0.0";
config->port = 8031;
config->connection_limit = 10;
config->buffer_size = 1024;
config->thread = false;
oyamo_server_set_config(config);
// Set the 'onconnect' event handler
oyamo_server_event_set_onconnect(on_connect);
// Start the OYAMO server
oyamo_server_go();
// Shutdown the OYAMO server
oyamo_server_shutdown();
return 1;
}
$ gcc main.c -loyamo -luuid -ljson-c
To install OYAMO, you can follow these steps:
- Update your package manager's list of available packages:
$ sudo apt update
- Upgrade any installed packages that have updates available:
$ sudo apt upgrade -y
- Clone the OYAMO repository:
$ git clone https://github.com/baygin/oyamo.git
- Change into the OYAMO directory:
$ cd oyamo
- Install the required dependencies:
$ make install-dependencies
- Build the OYAMO library:
$ make
- (Optional) Install OYAMO on your system:
$ sudo make install
If you want to contribute to the development of OYAMO, you can open an issue or submit a pull request.
OYAMO is licensed under the GPL3. See LICENSE for more information.