forked from cory/tildefriends
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:
@ -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);
|
||||
|
Reference in New Issue
Block a user