Cure.Server

The server is responsible for the communication between Elixir and C. The communication is based on Erlang Ports.

Summary

send_data(server, msg)

Sends binary data to the C-program that the server is connected with. A callback-function (arity 1) can be added to handle the incoming response of the C-program. If no callback is provided, the result is sent back to the process that called this function. If the third argument is :sync, this function blocks and returns the result

send_data(server, msg, callback)
start(program_name)

Starts a Cure.Server process and opens a Port that can communicate with a C-program

start_link(program_name)

Starts a Cure.Server process, links it to the calling process and opens a Port that can communicate with a C-program

stop(server)

Stops the server process

Functions

send_data(server, msg)

Specs:

  • send_data(pid, binary) :: :ok

Sends binary data to the C-program that the server is connected with. A callback-function (arity 1) can be added to handle the incoming response of the C-program. If no callback is provided, the result is sent back to the process that called this function. If the third argument is :sync, this function blocks and returns the result.

send_data(server, msg, callback)

Specs:

  • send_data(pid, binary, (binary -> any) | nil | :sync) :: :ok | binary
start(program_name)

Specs:

Starts a Cure.Server process and opens a Port that can communicate with a C-program.

start_link(program_name)

Starts a Cure.Server process, links it to the calling process and opens a Port that can communicate with a C-program.

stop(server)

Specs:

  • stop(pid) :: :ok

Stops the server process.