Code Monkey home page Code Monkey logo

oyamo's Introduction

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.

oyamo's People

Contributors

baygin avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

sserkanml platsek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.