bofc manual pages




psmq_init - initializes psmq object and initializes connection with the broker.  


#include <psmq.h>

int psmq_init(struct psmq *psmq, const char *brokername, const char *mqname, int maxmsg)  


Function initializes passed psmq object, opens brokername mqueue for writing, and creates mqname mqueue for reading with maxmsg. After successfull initializations of mqueue objects, function will register with the brokername and will send him mqname. mqname mqueue is used by the broker to send messages back to client.

Both mqname and brokername must start with '/' character (regardless of OS in use) and full name format is OS dependent. For example, QNX allows names with multiple '/', like "/name/of/mq", but Linux allows only one slash - at the beginning, so "/name" is only acceptable there. Refer to your system's manual about mqueue for details.

maxmsg defines how much messages can be queued in mqname before broker will start droping messages. If this value is not big enough, and your program is not quick enough to process incoming data from queue, when queue gets full, broker will drop incoming messages until there is place in the queue again. Lost packets are lost though.  


When all memory has been allocated properly and broker sends back register confirmation, 0 is returned. Else -1 is returned and appropriate errno is set.  


This eror is returned when at least one of these are true:
* psmq is NULL
* brokername is NULL
* brokername doesn't start with '/'
* mqname is NULL
* mqname doesn't start with '/'
* maxmsg is less than 1
* maxmsg is greater than maximum value supported by OS.
Length of the mqname is too big and cannot fit into payload that is sent to broker upon registration. This value is set during compile time, check psmq_building(7) for details.
Specified brokername doesn't exist. Either provided name is wrong, or broker is not running.
Broker is full of clients and won't accept any new connections until any of the clients disconnects.


Please, report all bugs to "Michał Łyszczek <>"  


psmqd(1), psmq-pub(1), psmq-sub(1), psmq_cleanup(3), psmq_init(3), psmq_publish(3), psmq_receive(3), psmq_subscribe(3), psmq_timedreceive(3), psmq_timedreceive_ms(3), psmq_unsubscribe(3), psmq_building(7), psmq_overview(7).

19 May 2021 (v9999)