@@ -4459,15 +4459,26 @@ int main(int argc, char ** argv) {
44594459 llama_backend_free ();
44604460 };
44614461
4462- // bind HTTP listen port
44634462 bool was_bound = false ;
4464- if (params.port == 0 ) {
4465- int bound_port = svr->bind_to_any_port (params.hostname );
4466- if ((was_bound = (bound_port >= 0 ))) {
4467- params.port = bound_port;
4468- }
4463+ auto suffix = std::string (" .sock" );
4464+ auto hostname = std::string (params.hostname );
4465+ if (hostname.compare (hostname.length () - suffix.length (), suffix.length (), suffix) == 0 ) {
4466+ LOG_INF (" %s: setting address family to AF_UNIX\n " , __func__);
4467+ svr->set_address_family (AF_UNIX);
4468+ // bind_to_port requires a second arg, any value other than 0 should
4469+ // simply get ignored
4470+ was_bound = svr->bind_to_port (params.hostname , 8080 );
44694471 } else {
4470- was_bound = svr->bind_to_port (params.hostname , params.port );
4472+ LOG_INF (" %s: binding port with default address family\n " , __func__);
4473+ // bind HTTP listen port
4474+ if (params.port == 0 ) {
4475+ int bound_port = svr->bind_to_any_port (params.hostname );
4476+ if ((was_bound = (bound_port >= 0 ))) {
4477+ params.port = bound_port;
4478+ }
4479+ } else {
4480+ was_bound = svr->bind_to_port (params.hostname , params.port );
4481+ }
44714482 }
44724483
44734484 if (!was_bound) {
0 commit comments