edelib 2.1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
SipcServer Class Reference

Simple IPC server. More...

`#include <edelib/Sipc.h>`

## Public Member Functions
| SipcServer ()
| ~SipcServer ()
bool | request_name (const char *prefix)
void | callback (SipcCallback cb, void *data)

## Detailed Description

Simple IPC server.

Sipc stands for Simple IPC (Inter Process Communication) and is very lighweight communication system between two processes by exchanging character messages based on UNIX domain sockets.

Sipc main purpose is to allow quick message exchanging when messages are simple (like simple notifications for refresh or quit) and there is no need for D-BUS, as heavier alternative (see EdbusConnection). It also minimizes linkage depenedencies (in D-BUS case) and can provide some sort of IPC support in places where D-BUS libraries does not exists.

SipcServer will listen incomming messages and will report them via registered callback. Before listening starts, you have to register name via request_name() adding prefix parameter; this name will be used by clients to connects to (same like port numbers, as you concluded already ;)).

If name is already taken, request_name() will fail and you will have to try with another one.

To listen for incomming connections, make sure you call listener_wait().

Here is the short sample:

void message_cb(const char* msg, void* arg) {
// sent messages will be in msg parameter
}
// in some function...
SipcServer s;
if(!s.request_name("demo"))
// fail
s.callback(message_cb);
// now listen infinitely for connections
while(1)
listener_wait();

Bidirectional communication is not possible (a case when server wants to reply); for that D-BUS exists :P

## Constructor & Destructor Documentation

SipcServer | ( |  | ) |

Constructor; prepares internal data

~SipcServer | ( |  | ) |

Cleans internal stuff, closes connections

## Member Function Documentation

void callback | ( | SipcCallback | cb,
|  | void * | data
| ) |  |

Register callback, called when message arrives.

Parameters

  cb | is callback
  data | is optional data passet to the callback

bool request_name | ( | const char * | prefix | ) |

Register name to be listening on. The name should be unique and not taken by other listener.

Returns
  false if failed or true otherwise

Parameters

  prefix | is name clients will use for connection

The documentation for this class was generated from the following file:

- edelib/Sipc.h