19#define BROADCAST_ADDR "255.255.255.255"
21int main(
int argc,
char* argv[]) {
39 bj_info(
"broadcast: sending announcements on port %d",
PORT);
44 int len = snprintf(message,
sizeof(message),
"BANJO_SERVICE:ping:%d", count++);
51 bj_info(
"broadcast: sent \"%s\"", message);
int main(int argc, char *argv[])
const char * bj_error_message(const struct bj_error *error)
Gets the error message from an error object.
void bj_clear_error(struct bj_error **error)
Frees an error and sets the pointer to NULL.
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
struct bj_udp * bj_open_udp(const char *host, uint16_t port, uint16_t hints, struct bj_error **error)
Opens a UDP socket bound to the specified port.
int bj_udp_send(struct bj_udp *udp, const char *host, uint16_t port, const void *data, size_t len, struct bj_error **error)
Sends a datagram to the specified destination.
void bj_close_udp(struct bj_udp *udp)
Closes a UDP socket.
@ BJ_RESOLVE_IPV4
Restrict address resolution to IPv4.
@ BJ_BROADCAST
Enable UDP broadcast (SO_BROADCAST).
bj_bool bj_begin(int systems, struct bj_error **error)
Initialises the system.
void bj_end(void)
De-initialises the system.
void bj_sleep(int milliseconds)
Suspends the current thread for a specified duration.
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for network API.
Header file for system interactions.
Header file for time manipulation utilities.