mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
Loading...
Searching...
No Matches
protocol_helper.h File Reference
#include "protocol.h"

Go to the source code of this file.

Functions

int send_cmd (struct protocol *cmd, int fd)
 Serialize and transmit a renderd protocol command message over a socket.
int recv_cmd (struct protocol *cmd, int fd, int block)
 Receive a renderd protocol command message from a socket.

Function Documentation

◆ recv_cmd()

int recv_cmd ( struct protocol * cmd,
int fd,
int block )

Receive a renderd protocol command message from a socket.

Performs a two-stage read to support backwards-compatible protocol versions:

  1. Reads the common struct protocol_v1 header prefix to determine cmd->ver.
  2. For protocol versions 2 and 3, reads the remaining version-specific trailing fields directly into cmd immediately after the v1 prefix.
Parameters
cmdDestination struct protocol buffer (zero-initialized before reading).
fdConnected socket file descriptor to read from.
blockNon-zero to block until the full message arrives (MSG_WAITALL), or 0 for non-blocking I/O (MSG_DONTWAIT).
Returns
Total bytes read (sizeof(protocol_v1), sizeof(protocol_v2), or sizeof(protocol)) on success; 0 if an incomplete message was read; -1 on EOF, socket error, premature close, or unknown protocol version.

◆ send_cmd()

int send_cmd ( struct protocol * cmd,
int fd )

Serialize and transmit a renderd protocol command message over a socket.

Validates the file descriptor and protocol version (1, 2, or 3), selects the wire structure size corresponding to cmd->ver (protocol_v1, protocol_v2, or full protocol v3), and sends the exact byte sequence via send().

Parameters
cmdPointer to the populated protocol command structure to transmit.
fdConnected socket file descriptor.
Returns
Number of bytes sent (matching the version's struct size) on success, or -1 (or a short byte count) on validation or socket error.