Thought I had a fundamental UDP broadcast problem, but it was just bad setup in the test.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4273 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
1359b48c9f
commit
2bffdb1168
21
src/ssb.c
21
src/ssb.c
@ -2111,6 +2111,11 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
||||
ssb->broadcast_timer.data = ssb;
|
||||
uv_timer_init(ssb->loop, &ssb->broadcast_timer);
|
||||
|
||||
ssb->trace_timer.data = ssb;
|
||||
uv_timer_init(ssb->loop, &ssb->trace_timer);
|
||||
uv_timer_start(&ssb->trace_timer, _tf_ssb_trace_timer, 100, 100);
|
||||
uv_unref((uv_handle_t*)&ssb->trace_timer);
|
||||
|
||||
if (!_tf_ssb_load_keys(ssb))
|
||||
{
|
||||
tf_printf("Generating a new keypair.\n");
|
||||
@ -2617,7 +2622,9 @@ static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address, s
|
||||
int r = uv_udp_try_send(&ssb->broadcast_sender, &buf, 1, (struct sockaddr*)&broadcast_addr);
|
||||
if (r < 0)
|
||||
{
|
||||
tf_printf("failed to send broadcast for %s (%d): %s\n", address_str, r, uv_strerror(r));
|
||||
char broadcast_str[256] = { 0 };
|
||||
uv_ip4_name(&broadcast_addr, broadcast_str, sizeof(broadcast_str));
|
||||
tf_printf("failed to send broadcast for %s via %s (%d): %s\n", address_str, broadcast_str, r, uv_strerror(r));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2672,9 +2679,6 @@ void tf_ssb_server_open(tf_ssb_t* ssb, int port)
|
||||
/* TODO: cleanup */
|
||||
return;
|
||||
}
|
||||
|
||||
tf_printf("Starting broadcasts.\n");
|
||||
uv_timer_start(&ssb->broadcast_timer, _tf_ssb_broadcast_timer, 2000, 2000);
|
||||
}
|
||||
|
||||
void tf_ssb_server_close(tf_ssb_t* ssb)
|
||||
@ -2911,17 +2915,16 @@ void tf_ssb_broadcast_sender_start(tf_ssb_t* ssb)
|
||||
|
||||
ssb->broadcast_sender.data = ssb;
|
||||
uv_udp_init(ssb->loop, &ssb->broadcast_sender);
|
||||
struct sockaddr_in broadcast_from = {
|
||||
struct sockaddr_in broadcast_from =
|
||||
{
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr.s_addr = INADDR_ANY,
|
||||
};
|
||||
uv_udp_bind(&ssb->broadcast_sender, (struct sockaddr*)&broadcast_from, 0);
|
||||
uv_udp_set_broadcast(&ssb->broadcast_sender, 1);
|
||||
|
||||
ssb->trace_timer.data = ssb;
|
||||
uv_timer_init(ssb->loop, &ssb->trace_timer);
|
||||
uv_timer_start(&ssb->trace_timer, _tf_ssb_trace_timer, 100, 100);
|
||||
uv_unref((uv_handle_t*)&ssb->trace_timer);
|
||||
tf_printf("Starting broadcasts.\n");
|
||||
uv_timer_start(&ssb->broadcast_timer, _tf_ssb_broadcast_timer, 2000, 2000);
|
||||
}
|
||||
|
||||
void tf_ssb_append_post(tf_ssb_t* ssb, const char* text)
|
||||
|
Loading…
Reference in New Issue
Block a user