Closed batsayan closed 3 years ago
Hello @batsayan ,
When you use a struct sockaddr_in
with ulfius_init_instance
, you must also set the struct sockaddr_in.port
value, because the port number specified in ulfius_init_instance
is no longer used.
listen.sin_port = htons(PORT);
Can you retry with that?
@babelouest This works, thanks. One observation, PORT parameter goes twice inside ulfius_init_instance API.
PORT parameter goes twice inside ulfius_init_instance API
Yes it does, it's a known limitation. I'll update the documentation to make it more obvious but to avoid breaking existing code, I'm not at ease to make aworkaround just for that.
Describe the issue The following code block works if (ulfius_init_instance(&instance, PORT, NULL, NULL) != U_OK) { printf("Error ulfius_init_instance, abort\n"); return(1); }
The following does not work struct sockaddr_in listen; listen.sin_family = AF_INET; listen.sin_addr.s_addr = htonl (INADDR_ANY); //listen.sin_addr.s_addr = inet_addr("10.10.140.148");
if (ulfius_init_instance(&instance, PORT, &listen, NULL) != U_OK) { printf("Error ulfius_init_instance, abort\n"); return(1); }
To Reproduce Use any sample application with or without the sockaddr_in parameters
Expected behavior sockaddr_in specified ulfius_init_instance() API should work
Screenshots Got the message "Failed to connect to localhost port 8080: Connection refused" when I use
(ulfius_init_instance(&instance, PORT, &listen, NULL)
System (please complete the following information):