Skip to content

baygin/oyamo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OYAMO - A Lightweight TCP/IP Library for C

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.

Prerequisites

  • gcc, clang, or another C compiler
  • Make
  • libuuid1
  • json-c

Features

  • 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

Example Server

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;
}

Compile

$ gcc main.c -loyamo -luuid -ljson-c

Other Examples

Installation

To install OYAMO, you can follow these steps:

  1. Update your package manager's list of available packages:
$ sudo apt update
  1. Upgrade any installed packages that have updates available:
$ sudo apt upgrade -y
  1. Clone the OYAMO repository:
$ git clone https://github.com/baygin/oyamo.git
  1. Change into the OYAMO directory:
$ cd oyamo
  1. Install the required dependencies:
$ make install-dependencies
  1. Build the OYAMO library:
$ make
  1. (Optional) Install OYAMO on your system:
$ sudo make install

Contributing

If you want to contribute to the development of OYAMO, you can open an issue or submit a pull request.

License

OYAMO is licensed under the GPL3. See LICENSE for more information.