Exemple #1
0
jnx_int32 send_discovery_request(discovery_service *svc) {
  char *tmp = "LIST";
  char *port = port_to_string(svc);
  jnx_socket_udp_broadcast_send(svc->sock_send,
                                svc->broadcast_group_address, port, (jnx_uint8 *) tmp, 5);
  return 0;
}
static void *worker_broadcast(void *args) {
  char *port = (char*)args;
  jnx_socket *t = jnx_socket_udp_create(AF_INET);
  JNXLOG(LDEBUG,"worker_broadcast firing...");
  jnx_socket_udp_broadcast_send(t,"255.255.255.255",port,(jnx_uint8*)"ping",5);
  return NULL;
}
Exemple #3
0
static void send_peer_packet(discovery_service *svc) {
  void *buffer;
  size_t len = peerton(peerstore_get_local_peer(svc->peers), &buffer);
  jnx_uint8 *message = malloc(4 + len);
  memcpy(message, "PEER", 4);
  memcpy(message + 4, buffer, len);

  jnx_socket_udp_broadcast_send(svc->sock_send, svc->broadcast_group_address, port_to_string(svc), message, len + 4);

  safely_update_last_update_time(svc);
  free(message);
  free(buffer);
#ifdef DEBUG
  debug_packet(svc, "PEER");
#endif
}