2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE)
20 * Formats a message (payload) of the given size and type and sends it to i3 via
21 * the given socket file descriptor.
23 * Returns -1 when write() fails, errno will remain.
24 * Returns 0 on success.
27 int ipc_send_message(int sockfd, const uint32_t message_size,
28 const uint32_t message_type, const uint8_t *payload) {
29 const i3_ipc_header_t header = {
30 /* We don’t use I3_IPC_MAGIC because it’s a 0-terminated C string. */
31 .magic = {'i', '3', '-', 'i', 'p', 'c'},
33 .type = message_type};
35 if (writeall(sockfd, ((void *)&header), sizeof(i3_ipc_header_t)) == -1)
38 if (writeall(sockfd, payload, message_size) == -1)