Poking at TCP binds from Haiku.
This commit is contained in:
parent
18bd279b0c
commit
e3071b372a
15
src/http.c
15
src/http.c
@ -619,15 +619,28 @@ int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cle
|
||||
|
||||
if (r == 0)
|
||||
{
|
||||
#if defined(__HAIKU__)
|
||||
/*
|
||||
** Binding to IPv6 here fails with an odd error, and the socket
|
||||
** becomes unusable. Since we probably want localhost only
|
||||
** on this single-user OS, let's just assume IPv4.
|
||||
*/
|
||||
struct sockaddr_in addr = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_addr = { .s_addr = INADDR_ANY },
|
||||
.sin_port = ntohs(port),
|
||||
};
|
||||
#else
|
||||
struct sockaddr_in6 addr = {
|
||||
.sin6_family = AF_INET6,
|
||||
.sin6_addr = IN6ADDR_ANY_INIT,
|
||||
.sin6_port = ntohs(port),
|
||||
};
|
||||
#endif
|
||||
r = uv_tcp_bind(&listener->tcp, (struct sockaddr*)&addr, 0);
|
||||
if (r)
|
||||
{
|
||||
tf_printf("uv_tcp_bind: %s\n", uv_strerror(r));
|
||||
tf_printf("%s:%d: uv_tcp_bind: %s\n", __FILE__, __LINE__, uv_strerror(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2843,13 +2843,14 @@ void tf_ssb_server_open(tf_ssb_t* ssb, int port)
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
if (uv_tcp_bind(&ssb->server, (struct sockaddr*)&addr, 0) != 0)
|
||||
int status = uv_tcp_bind(&ssb->server, (struct sockaddr*)&addr, 0);
|
||||
if (status != 0)
|
||||
{
|
||||
tf_printf("uv_tcp_bind failed\n");
|
||||
tf_printf("%s:%d: uv_tcp_bind failed: %s\n", __FILE__, __LINE__, uv_strerror(status));
|
||||
return;
|
||||
}
|
||||
|
||||
int status = uv_listen((uv_stream_t*)&ssb->server, SOMAXCONN, _tf_ssb_on_connection);
|
||||
status = uv_listen((uv_stream_t*)&ssb->server, SOMAXCONN, _tf_ssb_on_connection);
|
||||
if (status != 0)
|
||||
{
|
||||
tf_printf("uv_listen failed: %s\n", uv_strerror(status));
|
||||
|
Loading…
Reference in New Issue
Block a user