Bind tildefriends HTTP to an arbitrary port, write it to a file, and have the Android activity notice that file write and load the correct URL.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4233 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-03-18 12:28:48 +00:00
parent 63615747a7
commit d6be2f7d54
4 changed files with 102 additions and 12 deletions

View File

@ -456,7 +456,21 @@ void _socket_onResolvedForBind(uv_getaddrinfo_t* resolver, int status, struct ad
}
else
{
tf_task_resolve_promise(data->socket->_task, data->promise, JS_UNDEFINED);
struct sockaddr_storage addr = { 0 };
int port = 0;
int size = (int)sizeof(addr);
if (uv_tcp_getsockname(&data->socket->_socket, (struct sockaddr*)&addr, &size) == 0)
{
if (addr.ss_family == AF_INET)
{
port = ntohs(((struct sockaddr_in*)&addr)->sin_port);
}
else if (addr.ss_family == AF_INET6)
{
port = ntohs(((struct sockaddr_in6*)&addr)->sin6_port);
}
}
tf_task_resolve_promise(data->socket->_task, data->promise, JS_NewInt32(tf_task_get_context(data->socket->_task), port));
}
}
tf_free(data);