Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
tpzker

OETF #18 Open Inter-Process Communication Library

Recommended Posts

This is a draft. The library, and an example of compatible software will be coded later.

OIPCL or OIPC

Any OIPCL-compatible software MUST use the core OIPCL library and MAY use auxiliary IPC libraries.

Concepts

  • Open Inter-Process Communication Library (OIPCL): The library which provides a wrapper for the IPC sockets.
  • Socket: A file on the system which links two programs' communications.
  • OC: Abbreviation for "OpenComputers"
  • OS: Abbreviation for "Operating System"
  • OpenOS: The stock OS for OC computers.
  • Host: The program which is being linked to by a client.
  • Client: The program linking to a host.

Rationale

Due to the limitations of OpenOS, modifications would have to be made to many parts of the code to allow IPC within the core of OpenOS. To standardize any possible IPC libraries, a specification has been made.

  • Background programs (or daemons) can be started with a simple wrapper, such as this example code:
    thread.create(function()
    	shell.execute(ENV, "/bin/daemon.lua")
    end)

     

  • Host programs will be notified by an event, "oipcl_link_attempt", when a process is attempting to link to it.
  • Host programs can use the OIPCL's function to link to the process attempting to link to it.
  • Client programs can use the OIPCL's function to link to a background process which will automatically handle opening a socket and notifying the host.

Socket Format

A socket file is a Lua file which is processed by the host and the client through the OIPCL. It is a table containing a list of tables. The internal tables contain a string, "from", being either the host's specified name, or the client's specified name. They also contain a table, "messages", containing a list of strings. This allows a program to serialize any object into a message.

For example:

{
  {
    from = "client name",
    messages = {"EXEC", "/bin/script.lua"}
  },
  {
    from = "host name",
    messages = {"EXIT", "0"}
  }
}

Socket Naming

The socket files are be stored in /lib/oipcl along with the library file. They are named in this format:

oipcl-socket.[client name].[host name].lua

Socket Library

The OIPCL has 2 functions.

function linkToHost(clientName: string, hostName: string) -- will return a buffer that is a wrapper to the socket file
function linkToClient(clientName: string) -- will return a buffer that is a wrapper to the socket file

Signals

oipcl_link_attempt(clientName: string, hostName: string)

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.